I'm using a modified version of the keyboard hook code by Michael (viewtopic.php?p=600684#p600684), and a user has emailed me saying that my app doesn't let him type in his native language anymore, because the "dead keys" of a Portuguese layout aren't being recognized. I'm using the keyboard layout shown in the screenshot below.
So here's a small test snippet where basically I'm using his keyboard language and trying to hold down ^ and then type a to get ä. It's not working, and quite frankly I'm not sure how to fix it. What makes it harder is that my app does auto-completion of typed text, so as you can see in the snippet I'm using the "text$" variable to track what's been typed, so this needs to be taken in consideration as well.
Note: The snippet doesn't take the Shift key into account, but it should (so Shift+A should show "A" and not "a" like it does now).
The end goal is for "text$" to be Hi ä there when I type Hi {shiftdown}^{shiftup}a there.
PS: The snippet works perfectly fine with an English keyboard layout.

Code: Select all
Structure KeyboardState
b.b[256]
EndStructure
Global kbs.KeyboardState, Hook, text$
Procedure.l myKeyboardHook(nCode, wParam, *p.KBDLLHOOKSTRUCT)
If nCode = #HC_ACTION
If wParam = #WM_KEYUP Or wParam = #WM_SYSKEYUP
key = *p\vkcode
k$=Space(9)
ToAscii_(key,MapVirtualKey_(key,#MAPVK_VK_TO_CHAR),@kbs,@k$,0)
text$ + Trim(k$)
SetGadgetText(1, text$)
EndIf
EndIf
ProcedureReturn CallNextHookEx_(0, nCode, wParam, *p)
EndProcedure
OpenWindow(0,0,0,500,180,"Hook Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
StringGadget(0,10,10,480,130,"")
TextGadget(1,10,150,480,20,"")
SetActiveGadget(0)
SetWindowsHookEx_(#WH_KEYBOARD_LL,@myKeyboardHook(),GetModuleHandle_(0),0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
quit=1
EndSelect
Until quit

