0
votes

I'd like to map the Windows 10 virtual desktop switching feature to Windows key + mouse wheel with autohotkey.

My script looks like this:

LWin & WheelUp::Send ^#{Left}
LWin & WheelDown::Send ^#{Right}

The desktop switching works flawlessly, I can even hold down the Windows key and scroll up and down and it will change back and forth between desktops.

Unfortunately, if I keep holding down the Windows key for a little while after the last wheel action, the key release is sent to the OS which opens the start menu. Also, when I close the start menu afterwards (by pressing the windows key again) it switches back to the first virtual desktop I changed to (as if it had only received one "switch desktop" command).

So, my question is: how can I consume this key release in my script (and only for these two commands)?

Thanks in advance.

1

1 Answers

1
votes

Try this .

LWin & WheelUp::
    Send, {Ctrl Down}{LWin Down}{Left}
    SetTimer ReleaseKeys, 50
return

LWin & WheelDown::
    Send, {Ctrl Down}{LWin Down}{Right}
    SetTimer ReleaseKeys, 50
return

ReleaseKeys: 
    If not GetKeyState("LWin","P")  
    {
        SetTimer ReleaseKeys, off
        Send {Blind}{Ctrl Up}
        Send {Blind}{LWin Up}
        WinClose Start ahk_class Windows.UI.Core.CoreWindow
    }
return