1
votes

On Windows 8.1.

I assigned "Run Window Switcher" to "^r".
And now I want to close the window switcher when I release "LControl" but I don't know how.
With the normal "alt+tab" hotkey, it is closed when you release the key "alt".

The below snippet for opening the window switcher works fine. I can also shift the current window by clicking the "r" key keeping the "LControl" key down. (I copied "C:\Users\myname\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk" to "C:\Users\myname\Documents\" by the way)

^r::Run, "C:\Users\myname\Documents\Window Switcher"

But the below snippet for closing the window switcher doesn't work.

LCtrl Up::Send,{Enter}

Any help would be appreciated.

1

1 Answers

3
votes

A little hackish, but it still does the job fine:

^r::
    ; No need to rely on any shortcut here!
    Run, explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}
    KeyWait, Control
    if(WinActive("ahk_class TaskSwitcherWnd")) {
        Send, {Enter}
    }
return

#IfWinActive ahk_class TaskSwitcherWnd
^r::
    Run, explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}
return

The trick is to create two hotkeys: One that triggers if Window Switcher isn't already opened, and one that triggers if it is. The former "outer" hotkey will wait until CTRL is released and then close Window Switcher. The other "inner" hotkey registers every switch and delegates it.