Win+[key] hotkey sending a Win+[key] combo unreliable in AHK?

34 Views Asked by At

This simple code sometimes works and sometimes does not: #F1::#1 Sometimes it switches to the first app on the taskbar, sometimes it just types a 1. Why might that be?

The code I'm working on is:

#f2::
sleep 1000
Send {LWin down}
Loop 3
{
    Send 1  
    Sleep 100 
}
Send {LWin up}
Return

This switches to the third window of the first app on the taskbar. The sleep 1000 delays it too much to be of use to me, but if I omit it, or even change it to just sleep 100, it (usually?) doesn't work. I wonder if when I release the windows key it interprets it as a key-up before I get to send the 1, but it happens when I use trigger it by typing RWin+F2 too. I tried replacing the sleep with KeyWait, LWin, but that didn't help.

This seems like a simple question but I can't find anything about it. I tried using ~ and $ and {blind} and InputLevel, but none of them worked.

1

There are 1 best solutions below

0
Relax On

#F1::#1 isn't reliable.

Remapping doesn't release the modifier keys, because it uses the blind mode.

Use the Send command instead:

#Requires AutoHotkey v1.1

#f1::Send #1
#f2::Send {LWin down}111{LWin up}