Can I make Ctrl+Alt NOT act like AltGr on Windows?
I have researched further and looked at the other answers. It seems like the short answer is: No! Windows treats Ctrl+Alt and AltGr identically.
But there is a hack. Essentially we do not let Windows handle AltGr key bindings and instead use a third party tool that knows the difference. We do this manually for every singe key.
This hack does not work with "dead keys" such as ~ or ^.
.
Part 1: Let AutoHotKey convert AltGr+Some Key to symbols
AutoHotKey can distinguish between AltGr and Ctrl+Alt. It can also transform keystrokes like AltGr+2 to a single symbol @
, before Windows applies its keyboard layout.
- Download and install AutoHotKey
- Create a new script, i.e., a plain text file with the extension
.ahk
- For each character you want to write with AltGr+BUTTON=CHAR, create a line like this:
<^>!BUTTON::SendInput {raw}CHAR
Example: AltGr+2=@ becomes<^>!2::SendInput {raw}@
- Save the script
If you want to test your script, you can create some arbitrary mapping like <^>!t::SendInput {raw}tttt
. Double click the script to apply it and test if AltGr+t produces four t's when you type.
.
Part 2: Get windows out of the way:
We want to remove all assignments of AltGr+Any Key on they keyboard, so Windows never convert them into characters.
First we need to create a new keyboard layout.
- Download The Microsoft Keyboard Layout Creator. It is a simple tool that lets you modify your keyboard layout. (Download link)
- Open to tool and
File -> Load Existing Keyboard
and choose your keyboard layout. - Select
File -> Save source as
and give it a new name. - Tick the
Alt+Ctrl (AltGr)
.
You might want to selectFile -> Save as Image
to make a note of the original assignments. - Remove all assigned keys, by clicking them, deleting the symbol, and click
OK
Do not clear any dead keys! (The grey ones). Check for all modifiers i.e. AltGr, Ctrl, Alt, or none! - Go to
Projet -> Propertie
and give it a decent name and description. - Save it:
File -> Save Source File
so you can edit it later - Export setup:
Project -> Build DLL and Setup Package
Then we need to apply this new keyboard layout.
- Find the exported setup files in you Documents folder, and double click
setup.exe
. This will install your new keyboard layout. - Open the input setting by going to
Control Pannel -> Change keyboards and other input methods -> Change keybords
- Click
Add
select you own keyboard and make it default.
Come back here and remove the standard keyboard, once your confident everything works well.
.
Part 3: Let AutoHotKey take over:
Now lets put everything into action:
- Make sure your new keyboard is selected in the language task bar, and AutoHotKey is not running minimized in the notification tray.
- Try to type your special characters. This should not work.
- Double click on you AutoHotKey script. So it launches
- Try to type special characters again. This should now work with AltGr only.
- To make sure the script is loaded when Windows starts, create a short-cut to it in the
Start Menu\Programs\Startup
folder
That's it! (ツ) You can share the keyboard layout setup files and the .ahk
script, with other computers to skip most of the steps.
Other resources:
http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/replace-default-windows-keyboard-shortcut-behavior/0c5ff2a4-6bea-49a9-88bc-669049a1e107
http://office.microsoft.com/en-us/word-help/alt-gr-keys-HP005259063.aspx
https://devblogs.microsoft.com/oldnewthing/20040329-00/?p=40003
http://www.autohotkey.com/board/topic/61625-how-to-avoid-that-ctrl-alt-altgr/