When writing text the 7 German diacritical letters ä, Ä, ü, Ü, ö, Ö and ß are much more frequent than the symbols [, {, ], {, \, | and =. The corresponding keys are close together in the main keyboard area. Still, these symbols are frequent enough, so we must make them easy to type. What can be sacrificed is the simplicity of typing double diacritical characters, like ää, because they almost never occur.
Accordingly, the AHK script below remaps the symbols to the German characters. Pressing them twice in succession outputs the original symbols. Pressing Esc between them or moving the insertion point away and back produces double diacritical letters. So far this technique seems to be the fastest in typing, but it is limited to only a few special characters. If you need more, use the post modifier ring approach http://www.autohotke...opic.php?t=2383.
[ → ä [[ → [ [{Esc}[ → ää { → Ä {{ → { {{Esc}{ → ÄÄ ] → ö ]] → ] ]{Esc}] → öö } → Ö }} → } }{Esc}} → ÖÖ \ → ü \\ → \ \{Esc}\ → üü | → Ü || → | |{Esc}| → ÜÜ = → ß == → = ={Esc}= → ßß
Umlauts = äÄöÖüÜß Symbols = [{]}\|= Loop 7 ; init: Hotkeys, and Umlauts to be sent { StringMid U, Umlauts, %A_Index%, 1 StringMid S, Symbols, %A_Index%, 1 Transform n, ASC, %S% k%n% := U Hotkey $%S%, Remap } Loop ; lower priority process for non-hotkey keystrokes { ; Case sensitive, Ignore generated, 1 key Long, Modified keys go, Visible Input key, C I L1 M V key0 = %key% } Remap: StringRight key, A_ThisHotkey, 1 IfEqual key0, %key%, { ; repeated symbol Send {BS} Sendraw %key% key0 = } else { ; remapped key Transform n, ASC, %key% Send % k%n% key0 = %key% } returnThis might suffer from the same compatibility problems with some SW as described in http://www.autohotke...topic.php?t=540
If you change the insertion point immediately after a remapped symbol is inserted and at the new place you start with the same key (a very unlikely scenario), the script might try to replace the Umlaut with the original symbol. If it bothers you, append the following
#MaxHotkeysPerInterval 500 ; Needed for fast turning mouse wheel ~*BS:: ; restart if insertion point moves ~*Esc:: ~*Tab:: ~*Home:: ~*End:: ~*PgUp:: ~*PgDn:: ~*Up:: ~*Down:: ~*Left:: ~*Right:: ~*LButton:: ~*RButton:: ~*MButton:: ~*WheelDown:: ~*WheelUp:: ~*Ctrl:: ; restart if modifiers are pressed ~*Alt:: ~*LWin:: ~*RWin:: key0 = returnIf you most often write programs with German comments, you need the symbols more frequently than the Umlauts. In this case the opposite mapping is faster: double the symbols for the diacritics. It is straightforward to modify the script accordingly. In programs the pair of "==" is commonly used but not the pair "??", so it could be better to map ?→ ß, or whatever you like. It is enough to change the corresponding character in the Symbols variable.
Umlauts = äÄöÖüÜß Symbols = [{]}\|? Loop 7 ; init: Hotkeys, and Umlauts to be sent { StringMid U, Umlauts, %A_Index%, 1 StringMid S, Symbols, %A_Index%, 1 Transform n, ASC, %S% k%n% := U Hotkey $%S%, Remap } Loop ; lower priority process for non-hotkey keystrokes { ; Case sensitive, Ignore generated, 1 key Long, Modified keys go, Visible Input key, C I L1 M V key0 = %key% } Remap: StringRight key, A_ThisHotkey, 1 IfEqual key0, %key%, { ; repeated symbol Send {BS} Transform n, ASC, %key% Send % k%n% key0 = } else { ; remapped key Sendraw %key% key0 = %key% } returnInstead of checking if the insertion point moves, we can also add a timer, which cancels remapping a second after the last hotkey. In this case only fast key repetitions have effect. Simply add the line
IfGreater A_TimeSincePriorHotkey,1000, SetEnv,key0as the first line of the Remap subroutine. This last one is my favorite, so I copy it here one more time
; ; AutoHotkey Version: 1.0.30+ ; Language: English ; Platform: Win2000/XP ; Author: Laszlo Hars <www.Hars.US> ; ; Script Function: Remap American keyboards for German Umlauts Umlauts = äÄöÖüÜß Symbols = [{]}\|? ; change to your taste SetFormat integer, d ; decimal SetKeyDelay -1 ; no delay needed for the tested applications Loop 7 ; init: Hotkeys, 7 Umlauts to be sent { StringMid U, Umlauts, %A_Index%, 1 StringMid S, Symbols, %A_Index%, 1 Transform n, ASC, %S% k%n% := U Hotkey $%S%, Remap } Loop ; lower priority process for non-hotkey keystrokes { ; Case sensitive, Ignore generated, 1 key Long, Modified keys go, Visible Input key, C I L1 M V key0 = %key% } Remap: IfGreater A_TimeSincePriorHotkey,1000, SetEnv,key0 StringRight key, A_ThisHotkey, 1 IfEqual key0, %key%, { ; repeated symbol Send {BS} Transform n, ASC, %key% Send % k%n% key0 = } else { ; remapped key Sendraw %key% key0 = %key% } returnIt does the following remapping with 1s delay:
[[ → ä [{>1s}[ → [[ {{ → Ä {{>1s}{ → {{ ]] → ö ]{>1s}] → ]] }} → Ö }{>1s}} → }} \\ → ü \{>1s}\ → \\ || → Ü |{>1s}| → || ?? → ß ?{>1s}? → ??