I have the following code:
But toUnicode always returns 0. Any ideas what could be wrong?
Code:
#COMPILE EXE #DIM ALL %unicode = 1 #INCLUDE "win32api.inc" FUNCTION PBMAIN () AS LONG LOCAL vk AS DWORD, sc AS DWORD, flags AS DWORD LOCAL buffer AS WSTRINGZ * 2 LOCAL result AS INTEGER vk = %VK_X sc = MapVirtualKey(vk, 2) ' get scan code for the key flags = GetKeyboardLayout(0) result = ToUnicode(vk, sc, BYVAL 0, buffer, 2, flags) IF result > 0 THEN MSGBOX "Unicode character: " & buffer ELSEIF result < 0 THEN MSGBOX "ToUnicode error: " & STR$(GetLastError()) ELSE ' No translation available. MSGBOX "Nothing happened." END IF END FUNCTION
Comment