Switch Ctrl and Alt with AutoHotKey without messing up the Alt-Tab switcher?

I want to switch the Ctrl and Alt keys in Windows XP. I created an AutoHotKey script that contains the following:

LAlt::LCtrl
RAlt::RCtrl

LCtrl::LAlt
RCtrl::RAlt

This works, but the only problem is that the Alt-Tab switcher gets stuck. When I release Alt-Tab, the window switcher stays up until I hit another key or click the mouse.

Does anyone know how to fix this problem?


Solution 1:

I would like switch Alt and Ctrl because I'm currently a Mac user on Window (with a PC keyboard). All hotkeys on Mac: Cmd+n, Cmd+w ... -> PC: Ctrl+n, Ctrl+w and Cmd got same place as Alt key.

I found a non perfect solution:

Map all letters like that :

LAlt & a::Send {LCtrl Down}{a}{LCtrl Up}
...
LAlt & z::Send {LCtrl Down}{z}{LCtrl Up}
LCtrl & a::Send {LAlt Down}{a}{LAlt Up}
...
LCtrl & z::Send {LAlt Down}{z}{LAlt Up}

And you will keep Alt+Tab and AltGr functional

This is my full implementation (non complete): http://www.pastie.org/1660132

Solution 2:

I was looking for the same thing and found something that works without plugins or other programs. You can do it using the registry as described here.

Alternatively, just create 2 reg files. First the file for switching the Ctrl Key to Alt.

switch_ctrl-to-alt.reg

This adds the necessary key to the registry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1D,00,38,00,38,00,1D,00,00,00,00,00

And then the file for switching the Alt back to the Ctrl key.

switch_alt-to-ctrl.reg

This removes the necessary key from the registry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=-

After double clicking the reg-file you need to restart and you're good.