I couldn't get the method based on the keyboard creator to work. Instead, I came up with an AutoHotKey script. The method for detecting the current keyboard layout is taken from How to find out what is the current keyboard layout?.
The idea is to automate sending the sequence "dead key + space". Since this will have the wrong effect for layouts without dead keys, I filter based on the locale ID, which for the German keyboard fulfills the pattern 0x0407????
. This value may not be portable, given that keyboard layouts are not hardcoded.
I considered using GetKeyboardLayoutNameA
, but the value sometimes is outdated.
;;;; ------ NO DEAD KEYS ------
GetCurrentLocaleId()
{
;; Source:
;; https://autohotkey.com/board/topic/
;; 22900-how-to-find-out-what-is-the-current-keyboard-layout/
WinGet, WinID,, A
ThreadID := DllCall("GetWindowThreadProcessId", "Int", WinID, "Int", 0)
InputLocaleID := DllCall("GetKeyboardLayout", "Int", ThreadID)
Return InputLocaleID
}
IsGermanKbdLayout()
{
Return GetCurrentLocaleId()//0x10000 == 0x407
}
#If IsGermanKbdLayout()
SC029::SendRaw % "^ "
SC00D::SendRaw % "´ "
+SC00D::SendRaw % "`` "
;; Find scan codes by viewing script's console > view > key history
1
For non-German keyboards, see also When I type " nothing comes out, and if I type it again, 2 of it comes out as such: "" which explains about choosing some non-"US International" keyboard layout.
– Arjan – 2014-11-09T20:09:05.143Not only programming, you can't use console in games like quake/half-life properly. You have to delete crap every single time you open it. – Smit Johnth – 2017-01-28T20:17:05.293
6+1 programming on German Windows keyboards makes me go nuts. – slhck – 2011-05-06T08:59:29.613
2@slhck That's why I got several British/International layout keyboard, even in my laptops ;) – Daniel Beck – 2011-05-06T09:56:58.090
1I'm used to it so I don't want to change the layout. – ThiefMaster – 2011-05-06T10:14:53.233