Windows – How to remap Tab as Win key in AutoHotKey so it has two functions Tab and Win modifier

autohotkeykeyboardkeyboard shortcutsproductivitywindows 7

I would like to remap Tab key in such a way that:

  1. On Tab key down it BEHAVES AS WINDOWS(SUPER) KEY waits for extra key like ex: m or t and perform some action like maxize window(ex: WIN+m, WIN+t). It waits, and Tab repeating is blocked.
  2. On Tab key Up(alone) with no extra key, Tab key behave like normal Tab key (one Tab character)

How to write such an AutoHotKey script?

$Tab:: 
Send, {LWinDown}
KeyWait, Tab
if ( A_PriorKey = "LWinUp")
    Send, {LWinUp}          
else
    Send, {Tab}         
return

For the moment I have such a general solution but it still repeats Tab.

Best Answer

Due to similar issues of Alt Tab described in Autohotkey documentation. I decide to remap Win key to Tab key using SharpKeys software (Windows registry modification) and then apply ahk script

$LWin::
    KeyWait LWin, T0.15
    If !ErrorLevel ; if you hold the LWin key for less than 200 miliseconds...
        Send {Tab}
    Else ; but if it is held for more than that...
        Send {LWin Down} ; ...hold LWin down
    KeyWait LWin ; and, in both cases, wait for it to be released
    Send, {LWin Up}
Return

It is more stable and more universal solution than scripting Tab key directly with ahk: Answer related to: Win Up key as Tab key instead Windows Menu1