Hello!
Thanks for your reply. I managed to fix that. I was not providing the correct VK/SCs.
Now, I am having another problem. If you add in Windows the Yoruba or Igbo keyboard layouts and use AltGr, those extended unicode chars do not get inserted .... I tried with both: toAscii and toUnicode.
Here's how I changed them to suit my needs:
Code: Select all
toascii(uVirtKey,uScanCode,uFlags:=0) {
; Url:
; - https://msdn.microsoft.com/en-us/library/windows/desktop/ms646316(v=vs.85).aspx
; params:
; - uVirtKey, The virtual-key code to be translated.
; - uScanCode, The hardware scan code of the key to be translated. The high-order bit of this value is set if the key is up (not pressed).
; - uFlags, This parameter must be 1 if a menu is active, or 0 otherwise.
; return
; - corresponding character yielded by the combination of uVirtKey and whatever modifiers are down.
static lpKeyState
thread := DllCall("GetWindowThreadProcessId", "ptr", WinActive("A"), "ptr", 0)
hkl := DllCall("GetKeyboardLayout", "uint", thread, "ptr")
VarSetCapacity(lpChar, 4, 0)
if !lpKeyState
VarSetCapacity(lpKeyState,256,0)
for modifier, vk in {Shift:0x10, Control:0x11, Alt:0x12}
NumPut(128*(GetKeyState("L" modifier) || GetKeyState("R" modifier)) , lpKeyState, vk, "Uchar")
NumPut(GetKeyState("CapsLock", "T") , lpKeyState, 0x14, "Uchar")
n := DllCall("ToAsciiEx", "Uint", uVirtKey, "Uint", uScanCode, "UPtr", &lpKeyState, "ptr", &lpChar, "Uint", uFlags, "ptr", hkl)
return StrGet(&lpChar, n, "utf-16")
}
toUnicode(uVirtKey,uScanCode,wFlags:=0) {
; Url:
; - https://msdn.microsoft.com/en-us/library/windows/desktop/ms646320(v=vs.85).aspx
; params:
; - uVirtKey, The virtual-key code to be translated.
; - uScanCode, The hardware scan code of the key to be translated. The high-order bit of this value is set if the key is up (not pressed).
; - wFlags, The behavior of the function. If bit 0 is set, a menu is active. Bits 1 through 31 are reserved.
; return
; - corresponding character yielded by the combination of uVirtKey and whatever modifiers are down.
thread := DllCall("GetWindowThreadProcessId", "ptr", WinActive("A"), "ptr", 0)
hkl := % DllCall("GetKeyboardLayout", "uint", thread, "ptr")
VarSetCapacity(lpKeyState,256,0)
VarSetCapacity(pwszBuff,cchBuff:=3,0)
for modifier, vk in {Shift:0x10, Control:0x11, Alt:0x12}
NumPut(128*(GetKeyState("L" modifier) || GetKeyState("R" modifier)) , lpKeyState, vk, "Uchar")
NumPut(GetKeyState("CapsLock", "T") , &lpKeyState+0, 0x14, "Uchar")
DllCall("ToUnicodeEx", "Uint", uVirtKey, "Uint", uScanCode, "UPtr", &lpKeyState, "Uptr*", pwszBuff, "Int", cchBuff, "Uint", wFlags, "ptr", hkl)
return chr(pwszBuff)
}
I understand it's something about choosing the right encoding.
They differ a bit, in that toAscii throws Chinese looking like characters and the other, nothing. I need to display chars like ọ́ọ̀....
Thank you very much.
Best regards, Marius.