12

I'm trying to use autohotkey to simulate elements of Mac keyboard on a PC (Windows) keyboard. My muscle memory reaches for the Command key for simple tasks like copying and pasting, so I'd like to remap the left alt+letter key combinations to appropriate ctrl+letter.

<!c::Send ^c

Most of the time it works fine, except for part of the time in IE and Office applications. When pressing the left Alt, it screws with the office ribbon/menus (i.e. the menu bar shows in IE, or ribbon letters start appearing in Office 2010), and the ctrl+letter combination fired does not reach destination.

I've read the AHK FAQ + forums, tried a couple of options with UP and $ modifiers to the hotkey, but it did not fix the problem. Any ideas?

ttarchala
  • 4,277
  • 2
  • 26
  • 36

7 Answers7

14

This prevents the left-hand side Alt key from activating the menu bar for most applications (under Windows 7 and AutoHotkey 1.1.11.01):

~LAlt Up:: return

It doesn't work with Internet Explorer but I don't use IE often anyway. :)

BTW, I also killed the annoying start menu popup via:

~LWin Up:: return
~RWin Up:: return
zengabor
  • 2,013
  • 3
  • 23
  • 28
2

Use

LAlt::LCtrl

put it into a ahk file compile it and run .exe with administrator rights

right click -> Run as administrator

I tested it on Windows 7 and it works, LAlt no longer fires anywhere and it is completely replaced with LCtrl.

  • The "Run as administrator" does seem to do the trick with your mapping, but it's too global - I lose important Windows shortcuts such as Alt-Tab. Have you got any idea what might work with the more specific shortcuts such as those I made? – ttarchala Jan 16 '13 at 09:01
  • Prefixing the hotkey with tilde makes it even worse - now alt works normally, i.e. Alt+V opens View menu in IE rather than pasting the clipboard. Maybe I am doing something wrong? The relevant line from script now looks like this: `~<!v::Send ^v` – ttarchala Jan 16 '13 at 12:46
  • Read this: http://www.autohotkey.com/docs/Hotkeys.htm . You have two choices either make alt work as ctrl or not, the computer doesn't know when to activate alt or ctrl, if you want separate functions for a specific combination you have to code it. Read the docs, try it, write some code, if it doesn't help, post a question about a specific problem. –  Jan 16 '13 at 14:43
2

Just checked this on Win-7 and it works, even with IE.

00 00 00 00 00 00 00 00 03 00 00 00 1d 00 38 00 38 00 1d 00 00 00 00 00 00

Here is the SwapCtrlAlt.reg text.

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,00
Robert Ilbrink
  • 7,738
  • 2
  • 22
  • 32
  • Thanks for your answers, they deserve an upvote as quite informative, but I cannot really award the bounty. Like with other suggestions to swap alt with ctrl globally, I lose important Windows shortcuts such as Alt-Tab in this way, that is why I wanted to do this with AHK. Otherwise swapping alt with ctrl (or any other keys) can be done with the GUI utility KeyTweak, which I already know. – ttarchala Jan 21 '13 at 09:16
  • 2
    Just for your information, I checked if Send, {vkA4sc038} and Send, {vkA2sc01D} would work, but even if you disable Alt::Return and Ctrl::Return, IE continues to respond because it looks at the low level Scan Codes directly, so only a program (or regedit) that directly controls the scancodes will address this. – Robert Ilbrink Jan 25 '13 at 17:55
1

It sounds like you need the wildcard modifier. This will make it so if your hotkey is pressed in conjunction with another key. The mapping still works. Give the following a try:

*LAlt::LCtrl

This will make Alt fire Ctrl for any Alt+Key combination.

Syscall
  • 19,327
  • 10
  • 37
  • 52
Elliot DeNolf
  • 2,920
  • 1
  • 15
  • 12
  • Sorry to report that it didn't help. The IE menu bar, for instance, still flashes up when I press Alt, and it eats the Ctrl+key combination. It seems to me that I need a way for Windows to stop recognizing Alt as soon as it is down, and only recognize the whole key combination only once it has been fully pressed and depressed. – ttarchala Dec 19 '12 at 09:05
  • 1
    Ah, I do see this behavior. Mapping Alt to Return disables it, but once another combination is added, alt activates the menu. I tried a few things but was unable to come up with a solution. – Elliot DeNolf Dec 19 '12 at 15:50
1

Use

LAlt::LCtrl

this will replace LAlt with LCtrl

Syscall
  • 19,327
  • 10
  • 37
  • 52
dexter
  • 46
  • 2
0

you could also swap the two buttons.

Something like:

LAlt::LCtrl
LCtrl::LAlt

In the limited testing I did, it works, but you might need to relearn some of your window key shortcuts. It basically just swaps the two buttons.

EAKAE
  • 153
  • 1
  • 11
0

I am afraid that IE behaves differently from most other applications. You could try the instructions below. This is NOT autoHotKey but regedit changes. B.t.w. I had checked to see if ScanCodes would work (SC38 for LAlt), but IE still ignores that.

Not sure if this works in Vista/Win7/8, but worth a look.

http://www.designcodeexecute.com/2006/11/04/swap-alt-and-ctrl-keys-in-windows-xp/

Robert Ilbrink
  • 7,738
  • 2
  • 22
  • 32