Progam slowing down - MouseDown: extended delay

Asked by Shekhar on 2017-12-02


I am using sikuli for automating a game. The full code is pretty long but the part that moves / clicks mouse is as follows:-

class click_thread(threading.Thread):
    def __init__(self, reg_to_click):
        self.reg_to_click = reg_to_click
    def run(self):

def click_func(reg_to_click):
    while True:
        if auto_mouse == 'go':
            Settings.MoveMouseDelay = 0.1
            Settings.DelayBeforeMouseDown = 0.1
            Settings.ClickDelay = 0.1
            print((time.asctime(time.localtime(time.time()))),"click func recd call - waiting 1s")

click_lock = threading.Lock()

# auto_mouse is a global variable I use to 'pause' mouse actions if reqd by reassigning it from elsewhere

I am using threading to take care of mouse actions. Other functions in the code create a thread instance whenever they need the mouse to click something on the screen in the following way:-

            click_thread_instance = click_thread(reg_to_click)

The program slows down as it runs, resulting in a lot of 'timeouts' in the game i use it on. When i check logs, the most frequent entry seems to be 'MouseDown: extended delay'. I have tried running it both from IDE and the command line. It appears to make no difference to this problem. Any idea what might be causing this and what can be done to rectify it?

My env:-
OS:- Microsoft Windows 10 Home, 64-bit
Java:- Version 8, Update 151, build 1.8.0_151-b12
Sikuli: 1.1.1

Thanks in Advance.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Shekhar (shekharpr10015) said : #1

I tried to carry out the clicks via a function instead of using multi threading to see if it makes any difference:-

 def click_func(reg_to_click):
  while True:
   if auto_mouse == 'go':
    Settings.MoveMouseDelay = 0.1
    Settings.DelayBeforeMouseDown = 0.1
    Settings.ClickDelay = 0.1
    print((time.asctime(time.localtime(time.time()))),"click func recd call - waiting 1s")

All other functions in the script now call this function to get any clicking done. I am still experiencing the script slowing down gradually. Below are the latest logs:-

[debug] MouseDown: extended delay: 1026
[debug] MouseDown: extended delay: 1176
[debug] MouseDown: extended delay: 1493
[debug] MouseDown: extended delay: 1584
[debug] MouseDown: extended delay: 1658
[debug] MouseDown: extended delay: 3077
[debug] MouseDown: extended delay: 3248
[debug] MouseDown: extended delay: 3394
[debug] MouseDown: extended delay: 5769
[debug] MouseUp: extended delay: 1083
[debug] MouseUp: extended delay: 1094
[debug] MouseUp: extended delay: 1159
[debug] MouseUp: extended delay: 1263
[debug] MouseUp: extended delay: 1394
[debug] MouseUp: extended delay: 2123

Any advise / suggestions would be much appreciated on how to solve this problem.


RaiMan (raimund-hocke) said : #2

--- None of these settings make really sense:
            Settings.MoveMouseDelay = 0.1 # 0 would be the value, to switch of the mouse move animation
            Settings.DelayBeforeMouseDown = 0.1 # only relevant for dragDrop, no effect with click
            Settings.ClickDelay = 0.1 # time between down and up for click, standard is 0 which normally works.

--- click using a thread:
not needed with SikuliX 1.1.1+, since internally mouse actions are globally synchronized

--- extended delay
Internally SikuliX uses the Java AWT Robot class to handle mouse actions (Button up/down and move). All higher level mouse actions are composed based on these Robot features.
The error message comes up, when inside the Robot a feature like ButtonDown does not come back after a maximum delay (standard 1 second). This extended delay is not created by any SikuliX feature, but is completely in the layer between the Robot and the system mouse handling.

Since you are automating a game, it might well be, that the game engine is aware of the fact that the mouse actions are non-human and hence interferes the mouse handling with some delay, which seems probable looking at the continuous increase of the delay.

You might try, to implement your central click function using mouseDown() and mouseUp() with surrounding and intermediate short waits, that are randomly generated. This may help, to avoid being detected as a non-human.

Can you help with this problem?

Provide an answer of your own, or ask Shekhar for more information if necessary.

To post a message you must log in.