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