AutoHotkey's standard approach is to convert each character to a key or combination of keys. Failing that, it falls back to Alt+Numpad (in ANSI builds) or the Unicode mode of SendInput(). However, some (very few, I think) keyboard layouts use non-standard shift states, such as the "Hankaku" key on Japanese keyboards and Mod3/Mod4 on the Neo layout. In v1.1.00.01 I added a check for the "Hankaku" shift state (which is Mod4 on the Neo layout) to avoid sending (the wrong) keystrokes for characters which require it. However, I didn't know additional shift states were even possible, let alone how to detect them.
I do now:
Quote:
... the high-order byte contains the shift state, which can be a combination of the following flag bits.
1 - Either SHIFT key is pressed.
2 - Either CTRL key is pressed.
4 - Either ALT key is pressed.
8 - The Hankaku key is pressed
16 - Reserved (defined by the keyboard layout driver).
32 - Reserved (defined by the keyboard layout driver).Source: VkKeyScanEx Function
For "(" on the Neo2 layout, VkKeyScanEx returns 0x104E, which is a combination of shift state 0x10 (16) and the virtual keycode for "N". It's probably safe to say that any time these unsupported shift states (8, 16 or 32) are returned, ignoring them will give incorrect results. So I'll update the code to fall back to the Unicode mode of SendInput() when these shift states are returned. (As mentioned above, this is already done in v1.1.00.01+ for shift state 8.)
The following script can be used on any Unicode build of AutoHotkey to determine which characters use unsupported shift states:
Code:
MsgBox Switch to desired keyboard layout, then click OK.
SetFormat IntegerFast, H
Loop % 0xFFFF {
r := DllCall("VkKeyScan", "ushort", A_Index, "short")
if (r != -1 && (r & 0x3800))
s .= Chr(A_Index)
}
MsgBox % s="" ? "No unsupported shift states are used by this layout." : s
With the Neo2 layout active, I get the following:
Code:
!"#$%&'()*+,./26:;<=>?@[\]_{|}~ ¡¢£¤¥¨ª¬¯±²³µ·¹º¿×÷ſ˘˙˚˝˞ΓΔΘΛΞΠΣΦΨΩαβγδ
εζηθικλνξοπρςστυφχψωϑϕϰϱϵ᾿῾‑‘’‚†‣… ‹›₀₁₂₃ℂℕ№ℚℝℤℵ←↑→↓↔↕↦↻⇌⇐⇒⇔∀∂∃∅∇∈−∘√
∝∞∡∥∧∨∩∪∫⊂⊗⊥⋅␣♀♂♣♥♦♫⚥✔✘⟨⟩
Note that "2" and "6" are shown. This is because the Neo2 keyboard layout contains more than one way to map these characters, but VkKeyScan and VkKeyScanEx can only tell us one way. According to the following blog article, which value is returned depends on the order of entries in the keyboard layout table:
If you replace 0x3800 in the code above with 0x800, it will show all characters which use Mod4/Hankaku, including "2" and "6" in the Neo layout. These characters should already work okay in v1.1.00.01+.