Java机器人鼠标移动:设置速度?
Java Robot 类允许人们移动鼠标,就像移动实际的物理鼠标一样。
然而,如何以人性化(而非即时)的方式将鼠标从 Point1 移动到 Point2?又名,如何设置移动速度?
如果Robot类不可能达到这样的速度,那么如果鼠标只能瞬时移动,那么应该使用什么样的“算法”来模仿人类的鼠标移动?是否应该以一定的递增速度逐像素移动鼠标?
The Java Robot class allows one to move the mouse as if the actual physical mouse was moved.
However, how does one move the mouse from Point1 to Point2 in a humane (and thus not instant) manner? Aka, how does one set the speed of movement?
If no such speed is possible with the Robot class, thus if the mouse can only be moved instantenously, what kind of "algorithm" should be used to mimic a human's mouse movement? Should it move the mouse pixel by pixel with a certain incrementing speed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一个非常好的方法:
考虑鼠标开始的
start_x
和您希望鼠标结束的end_x
。y
也一样希望有帮助......
Here is a pretty good way here:
Consider
start_x
where your mouse starts andend_x
where you are wanting it to end. Same fory
Hope that helps...
Robot 类有一个delay(...) 方法,您可以使用它来控制从一个点到另一个点的移动。尝试几种不同的算法来确定您喜欢的算法。
The Robot class has a delay(...) method that you can use to control movement from point to point. Try a few different alogorithms to determine what you like.
重写 Geoff 的答案以便于理解:
Rewrite Geoff's answer for easier understanding: