I do not know what changed, but I am able to reproduce this now.
It cannot be an
AutoHotkey bug that an OS component is reacting to a key press before notifying AutoHotkey that the key was pressed.
Tensai wrote:The OS seems to be using a lower keyboard hook than ahk for Aero Peek.
Anytime a key is pressed it will cancel the hover preview, then pass the key through.
さすが天才
It is a good guess, but not quite right; it is likely not
lower, just
more recent. As far as I can tell, the thumbnail handler is registering a keyboard hook when it shows or moves the thumbnail. As the most recently registered hook is called first, the thumbnail is always notified of any keyboard event before any previously-registered hooks. It does not matter whether those other hooks return the "suppress this" value, because by then the thumbnail has already been hidden. It appears that sliding the mouse across the taskbar moves the existing window instead of creating a new one, but still refreshes the thumbnail's keyboard hook.
Attempts to work around this may be disruptive and unreliable. Basically you need AutoHotkey's hook to be unregistered and re-registered every time a thumbnail window is shown or moves. This can be done in script by temporarily suspending hotkeys, unless you have hotkeys or hotstrings which are exempt from suspension, or something else actively requiring the hook (such as Input/InputHook). This appeared to be sufficient:
Code: Select all
#Requires AutoHotkey v1.1
#Include <D>
; #Warn
Loop {
WinWait ahk_class TaskListThumbnailWnd
if !A_IsSuspended {
Suspend On
Suspend Off
}
WinGetPos oldx, oldy
Loop {
Sleep 20
WinGetPos x, y
if (x = "")
break
if (x != oldx || y != oldy)
break
}
}
NumpadIns::
+NumpadIns::
^NumpadIns::
^+NumpadIns::
{
Click, Down
keywait, NumpadIns
Click, Up
}
Return
Alternatives include using a timer instead of a loop, or using other types of hooks to detect the thumbnail window (SetWinEventHook or perhaps RegisterShellHookWindow).
For v2,
InstallKeybdHook(,true) can be used instead of suspending hotkeys, and will re-register the hook even if some hotkeys are exempt from suspension.
Even this workaround would be completely ineffective for registered hotkeys, because they do not use AutoHotkey's hook; the OS decides how to handle them.