Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using auto hotkey to swap Ctrl & Alt and implement Ctrl Tab

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?

like image 668
whomba Avatar asked Aug 26 '13 23:08

whomba


3 Answers

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   
like image 170
JPGInc Avatar answered Nov 14 '22 04:11

JPGInc


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  
like image 6
Joshua Cave Avatar answered Nov 14 '22 04:11

Joshua Cave


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

like image 1
Ryan Avatar answered Nov 14 '22 06:11

Ryan