[Moderator's note: Topic moved from Bug Reports.]
I use VS Code to write the AHK2 scripts for automatic installation of .exe files on Win11, but SetMouseDelay() does not work here, which leads to poor stability of the script .
The following are two demonstration videos I recorded. The mouse has been highlighted by the screen recorder. The frame rate of both videos is 30fps.
[*]In Test1, I let the mouse move randomly in a long enough loop;
[*]In Test2, I copied 1000+rows of MouseMove statements directly.
We can see that the mouse movement speed of Test1 is significantly faster than the preset 2000 milliseconds, while in Test2, the MouseMove of 1000+lines was executed in less than 2 seconds.
[v2.0-beta.15]: SetMouseDelay() does not work on Win11 Topic is solved
-
- Posts: 6
- Joined: 22 Nov 2022, 04:16
Re: [v2.0-beta.15]: SetMouseDelay() does not work on Win11
It do not believe it is possible that SetMouseDelay would fail to work due to a difference in OS.
SetMouseDelay is not intended to have any effect with the SendInput mode. This is probably not clear in the documentation, but is noted.
SetMouseDelay is not intended to have any effect with the SendInput mode. This is probably not clear in the documentation, but is noted.
By contrast,A short delay (sleep) is done automatically after every mouse movement or click generated by Click and MouseMove/Click/Drag (except for SendInput mode).
SendInput is the default mode in v2.Note: SetKeyDelay is not obeyed by SendInput; there is no delay between keystrokes in that mode. This same is true for Send when SendMode Input is in effect.
-
- Posts: 6
- Joined: 22 Nov 2022, 04:16
Re: [v2.0-beta.15]: SetMouseDelay() does not work on Win11
@lexikos
I'm sorry to have noticed your reply so late.
In fact, as a novice in the AHK scripting language, I can only write scripts with the help of reference help documents, so I have already noticed that:
In addition, you mentioned SendInput(), which makes me puzzled, because the function I tested does not include SendInput() at all. In the attachment I uploaded, I only tested the behavior of MouseMove().
My test code has been described in the original topic and shown in the attached video. However, to avoid ambiguity, I will attach my code here.
Test1:
Test2:
I'm sorry to have noticed your reply so late.
In fact, as a novice in the AHK scripting language, I can only write scripts with the help of reference help documents, so I have already noticed that:
Yes, the mouse movement event has a default delay, but this default delay must not be the 2000 ms I specified, right? The problem now is that in my case, even if I set the mouse delay as high as 2000 ms, the mouse movement will not have a significant delay (ideally, it should be 2 seconds apart between its two movement events, which is long enough to be clearly perceived by the naked eye).A short delay (sleep) is done automatically after every mouse movement…
In addition, you mentioned SendInput(), which makes me puzzled, because the function I tested does not include SendInput() at all. In the attachment I uploaded, I only tested the behavior of MouseMove().
My test code has been described in the original topic and shown in the attached video. However, to avoid ambiguity, I will attach my code here.
Test1:
Code: Select all
CoordMode("Mouse", "Screen")
SetMouseDelay(2000)
i := 1
while(i < 100000){
MouseMove(Random(200, 1200), Random(200, 1200))
i++
}
Code: Select all
CoordMode("Mouse", "Screen")
SetMouseDelay(2000)
MouseMove(Random(200, 1200), Random(200, 1200))
MouseMove(Random(200, 1200), Random(200, 1200))
MouseMove(Random(200, 1200), Random(200, 1200))
MouseMove(Random(200, 1200), Random(200, 1200))
MouseMove(Random(200, 1200), Random(200, 1200))
; In the actual test, the statement in the previous line repeated 1000+lines to observe the obvious phenomenon.
; For the sake of presentation, the repeated code of the following hundreds of lines is omitted here.
Re: [v2.0-beta.15]: SetMouseDelay() does not work on Win11 Topic is solved
Please note the emphasis.
Also, in the documentation for MouseMove, which you are directly using:except for SendInput mode
...
This same is true for Send when SendMode Input is in effect.
...
SendInput is the default mode in v2.
Try with SendMode "Event".This function uses the sending method set by SendMode.
-
- Posts: 6
- Joined: 22 Nov 2022, 04:16
Re: [v2.0-beta.15]: SetMouseDelay() does not work on Win11
Thank you for your prompt reply. I carefully read the documentation again and set SendMode to Event. After that, the script ran as scheduled.lexikos wrote: ↑03 Dec 2022, 23:39Please note the emphasis.Also, in the documentation for MouseMove, which you are directly using:except for SendInput mode
...
This same is true for Send when SendMode Input is in effect.
...
SendInput is the default mode in v2.Try with SendMode "Event".This function uses the sending method set by SendMode.
Because I used to understand it literally, I mistakenly thought that SendMode only affected Send() series functions. Now that I have realized that this is not a bug, it may be more appropriate to move this topic to the "AutoHotkey>Ask For Help>AutoHotkey v2 Help" section.
You are a dedicated and kind developer. Thank you again.