I'm changing the Caps key to Ctrl by using this registry key:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]             

And I want to use the original Ctrl key as another modifier for AutoHotkey. So I thought Alt GR is a good choice to use as a modifier.

But I couldn't figure out how to remap the original Ctrl key to Alt GR. Does anyone know how to change it via registry?

If there is better solution, I will go for it.

I'm using windows 10.

  • ::Ctrl; Send {alt}{GR}; Is that the result you're looking for? – ejbytes Jun 3 '16 at 23:16
  • @ejbytes The way I read it, he is looking to change his Ctrl key to an AltGr key in way that AHK doesn't recognize his Caps Lock key as a Ctrl key, because he edited the registry to rebind it that way. – TheKB Jun 4 '16 at 9:01
  • @ejbytes Sorry, I couldn't figure out how the code works. – ironsand Jun 4 '16 at 21:06
  • @TheKB I want let AHK recognize Caps Lock as a Ctrl and original Ctrl as a AltGr. I'm not sure I'm understanding correctly what you wrote. – ironsand Jun 4 '16 at 21:08
  • @ironsand Yes, that's what I wrote. – TheKB Jun 5 '16 at 8:36

Method 1: Use SharpKeys

You could use SharpKeys to remap your keys. This changes the registry for you and allows you to easily manage key mappings.

  1. Click Add on the main screen
  2. Under Map this key click Type Key and press Ctrl
  3. Under To this key find and click AltGr
  4. Click Ok
  5. Click Write to Registry and then logout

Note: You may have to do steps 1-4 again for Caps to Ctrl
Edit: It appears that the key AltGr is not supported by SharpKeys. However, this answer is still valid for other keys so I will leave it for informational purposes. The registry method of rebinding, outlined below, works for this key remap.

Method 2: Use the Registry

If you want to do it via the registry you can do:

00 00 00 00 00 00 00 00 03 00 00 00 aa aa bb bb aa aa bb bb 00 00 00 00

It's a bit complicated but I will try to explain. For remap 1, aaaa is the scancode of the key you want to map to. bbbb is the scancode of the key you want to map from. Same thing for remap 2. This is what you would put into the registry key ScancodeMap and what SharpKeys does for you.

A table showing the values and meaning of the DWORDS:

        Value:     Interpretation:                                          Entered as: 
DWORD 1 0x00000000 Header: Version. Set all to zeroes                       00 00 00 00 
DWORD 2 0x00000000 Header: Flags. Set all to zeroes                         00 00 00 00 
DWORD 3 0x00000002 Number of entries in the map, including null terminator  02 00 00 00 
DWORD 4 0x003A0000 Remove CAPS LOCK (0x3A --> 0x00)                         00 00 3A 00 
DWORD 5 0x00000000 Null Terminator                                          00 00 00 00 

In the above table, the mapping of Caps Lock is an example. Also, thanks to @Guitar Shoe Dave for the suggestion.

In your case the value would be:

00 00 00 00 00 00 00 00 03 00 00 00 1d 00 3a 00 1d 02 1d 00 00 00 00 00

Note: You'll have to logoff and back in again to see the resulting changes.

  • I installed SharpKeys, but I couldn't find AltGr key in to this key list. What is the exact name of the key? – ironsand Jun 4 '16 at 21:19
  • @ironsand It appears that it is not there. But I believe 1d02 is the scancode for AltGr (I used the on-screen keyboard to test this) So the registry entry would be 00 00 00 00 00 00 00 00 03 00 00 00 1d 00 3a 00 1d 02 1d 00 00 00 00 00. Could you try this and see if you get the correct results? – TheKB Jun 5 '16 at 11:59
  • Please consider adding protocol documentation related to scancodes. Here's one which breaks it down a bit. mech.utah.edu/~bamberg/resources/CapsLock/CapsLock.html Also, here's a good reference of scancodes to include the long lived power management buttons (these ones are fun to play with) win.tue.nl/~aeb/linux/kbd/scancodes.html . I love your reply. – NotAdmin Dave Jun 9 '16 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.