reproduced it a few times now in a new tidy script, in different applications (one beeing notepad), best try took me 70 keypresses, worst was beyond 400
keyhistory: (replaced f with d too exclude the possibilty of an broken "f" key on my keyboard)
Code: Select all
52 013 i d 0.17 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
44 020 h d 0.02 d <--- physical press
44 020 s u 0.14 d <--- up event
52 013 i d 0.02 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
44 020 h d 0.03 d <--- physical press (script locked on d down)
A0 02A i d 0.14 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
another keyhistory:
Code: Select all
52 013 i u 0.00 r
44 020 h d 0.11 d <--- physical press
A0 02A i d 0.06 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
44 020 s u 0.09 d <--- up event
52 013 i d 0.08 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
44 020 h d 0.03 d <--- physical press (script locked on d down)
A0 02A i d 0.14 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
A0 02A i d 0.17 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
44 020 h d 0.14 d <--- physical press
A0 02A i d 0.03 LShift
52 013 i d 0.00 r
52 013 i u 0.00 r
A0 02A i u 0.00 LShift
44 020 s u 0.14 d <--- up event
52 013 i d 0.03 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
52 013 i d 0.17 r
52 013 i u 0.00 r
here is the test script, would love for someone to try reproduce this on his machine. Any thoughts why this could happen? Possible fixes?
Code: Select all
#NoEnv
#InstallKeybdHook
#InstallMouseHook
#KeyHistory 500
#Persistent
#SingleInstance force
#MaxHotkeysPerInterval 10000
#HotkeyInterval 10000
; ListLines Off
SendMode Input
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
SetKeyDelay, -1, -1
SetWinDelay, -1
SetControlDelay, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
Gui, 50:+AlwaysOnTop
Gui, 50:Add, Text, cBlue vgui1 x10 y10 w120, N/A
Gui, 50:Add, Text, cBlue vgui2 x140 y10 w120, N/A
Gui, 50:Show, x1580 y980 W320 H40
foo := 1
keypresses := 0
step()
$d::
keypresses++
return
F1::
foo := 0
Suspend
return
F10::ExitApp
step() {
global
while (foo == 1) {
sleep 170
dllstate := DllCall("GetKeyState", Uint, 0x44)
dllstateasync := DLLCall("GetAsyncKeyState", Uint, 0x44)
if (GetKeyState("d", "P")) {
send +r
GuiControl, 50:, gui1, % "d PRESSED DOWN" . " dll:" . dllstate . " adll:" . dllstateasync
} else {
GuiControl, 50:, gui1, % "d released" . " dll:" . dllstate . " adll:" . dllstateasync
send r
}
GuiControl, 50:, gui2, % keypresses
}
return
}
EDIT1: tested it without the $d:: hotkey set, still occurs
also the logical state seems to revert to normal, only physical has this bug.
DllCall("GetKeyState", Uint, 0x44) and DLLCall("GetAsyncKeyState", Uint, 0x44) return 0 after i physically release the key, obviously those are no help when i block the $d key (which is required in my original script)
EDIT2: tested without shift modifier, still occurs
EDIT3: unable to reproduce when the script does not send hotkeys itself, 1500 keystrokes in and my fingers need a break
EDIT4: could it have something to do with
this?
SendInput and SendPlay [v1.0.43+]: SendInput and SendPlay use the same syntax as Send but are generally faster and more reliable.
In addition, they buffer any physical keyboard or mouse activity during the send, which prevents the user's keystrokes from being interspersed with those being sent. SendMode can be used to make Send synonymous with SendInput or SendPlay. For more details about each mode, see SendInput and SendPlay below.
EDIT5: unable to reproduce when SendMode Event is used (1000 keystrokes tested)
The autohotkey source is exceptionally well documented btw. Still, hard to find the right spot for when the buffering mentioned in EDIT4 is taking place, is keyboard_mouse.cpp the right place to look?
Code: Select all
if (sSendMode == SM_INPUT)
{
// Remove hook(s) temporarily because the presence of low-level (LL) keybd hook completely disables
// the uninterruptibility of SendInput's keystrokes (but the mouse hook doesn't affect them).
im getting the feeling that my bug is a feature