While using AutoHotKey I wanted to setup a rule to swap the left alt and left ctrl. I can do this by doing:
LAlt::LCtrl
LCtrl::LAlt
I then wanted to keep the 'alt tab' functionality bound do those physical keys, thus I tried
LCtrl & Tab::AltTab
In addition to the two uptop, yet it won't work. If I put it like so:
LCtrl & Tab::AltTab
LAlt::LCtrl
LCtrl::LAlt
Then the tab will work, however the ctrl alt swap will be broke. Any suggestions?
The hotkey documentation talks about wildcards
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:
*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey.
*ScrollLock::Run Notepad ; Pressing Scrolllock will trigger this hotkey even when modifer key(s) are down.
So try this
*tab::
{ if(GetKeyState("LAlt", "P"))
{ Send {LControl up}{Alt down}{tab}
KeyWait, tab
}else
{ send {tab}
}
return
}
~LAlt Up::
{ send {lalt up}
return
}
LAlt::LCtrl
LCtrl::LAlt
I improved this slightly to fix shift tab not working, now you can use Shift+tab as expected where as before you couldn't (was frustrating trying to fix indentation(outdent) when coding) I may improve this more and get Shift+Alt+Tab working
*tab::
{
if(GetKeyState("LAlt", "P")){
Send {LControl up}{Alt down}{tab}
KeyWait, tab
} else if(GetKeyState("LShift", "P")){
Send {LShift down}{tab}
KeyWait, tab
}else
{ send {tab}
}
return
}
~LAlt Up::
{ send {lalt up}
return
}
LAlt::LCtrl
LCtrl::LAlt
Just ran into the same problem myself, was looking for a more straightforward solution. If you swap Alt and Ctrl using SharpKeys (or other registry remapping tool) from there it's a simple:
RCtrl & Tab::AltTab
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With