拖放机器人类
我想使用 Java 中的 Robot 类进行拖放。由于某种原因,下面的代码不起作用。这种方法有替代方法吗?
public static void main (String args []){
Robot robot = new Robot ();
robot.mouseMove(350, 226);
robot.keyPress(InputEvent.BUTTON1_MASK);
robot.mouseMove(250, 350);
robot.keyRelease(InputEvent.BUTTON1_MASK);
}
I would like to drag and drop using the Robot class in Java. For some reason the code below isn't working. Is there an alternative to this method?
public static void main (String args []){
Robot robot = new Robot ();
robot.mouseMove(350, 226);
robot.keyPress(InputEvent.BUTTON1_MASK);
robot.mouseMove(250, 350);
robot.keyRelease(InputEvent.BUTTON1_MASK);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
mousePress()
和mouseRelease()
,而不是keyPress()
和keyRelease()
You need to use
mousePress()
andmouseRelease()
, notkeyPress()
andkeyRelease()
这对任何人和你都有帮助:
This is helps anyone and you: