How to simulate mouse clicks as fast as possible in Java? -


i'm simulating mouse clicks , want fast possible.

currently i'm using robot class this:

private static int millisecondclickdelay = 25;  public static void leftclickmouse(){     main.robot.mousepress(inputevent.button1_down_mask);     main.robot.mouserelease(inputevent.button1_down_mask);     main.robot.delay(millisecondclickdelay);     main.robot.mousemove(0, 0); } 

unfortunately have use delay, or else race condition mouse moves before release registered.

25 lowest delay can use without encountering problem, task i'm doing takes 14 seconds this. i've gotten down 6 seconds 5 millisecond delay, result horribly inconsistent.

can simulate clicks way?

thanks in advance.

update:

i've updated function this:

public static synchronized void leftclickmouse(){     main.robot.mousepress(inputevent.button1_down_mask);     main.robot.mouserelease(inputevent.button1_down_mask);     main.robot.waitforidle();     main.robot.mousemove(0, 0); } 

the robot.waitforidle() waits until events on event queue have been processed, problem still there.

i'm assuming application acting on non java application. stuck setting delays.

if being done in java application interact itself, use swingutilies , add each robot action awt thread. allow mouse pressed/released events processed application.

i guess need more info. application interacting with? if not application itself, stuck adding delays in. i'd working increase delays atleast 20% safety factor. i'd see works consistently , double delays.

depending on doing, try setting priority of target application realtime , java application lowest priority in task manager. might bit doesn't resolve problem.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -