Java robot class mouseMove not going to specified location

后端 未结 1 838
滥情空心
滥情空心 2021-01-13 20:07

To be honest I am not entirely sure what is wrong. This is the short version of a ton of other basic robot command movements under the if and if else.

Whenever I

相关标签:
1条回答
  • 2021-01-13 20:49

    As a disclaimer, I was playing around with this class for a while, and the most important thing I learned was this was a tool meant for very rudimentary testing, and really no large scale crucial operation should ever hinge on this class working exactly as expected.

    To answer your question, there is really no way to get exactly where you tell mouseMove() to go (at least not when I was working with it). However, what seemed to get it pretty close was to call mouseMove() multiple times to the same place (Yes, this is very hacky and not desirable). For example, is I wanted to move the mouse to (300,600) on screen, I found that if you do:

    mouseMove(300,600);
    mouseMove(300,600);
    mouseMove(300,600);
    // ... can put more if you want
    

    for some strange reason it gets much closer to where you want to go than if you just call mouseMove() one time. I have no idea why this might be the case, but hopefully this helps. Not to mention, it is also a good idea to put ample delays in between calling the robot to do different actions, and to ensure that waitForIdle() is invoked.

    0 讨论(0)
提交回复
热议问题