-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathGetKeyChar.ahk
33 lines (30 loc) · 925 Bytes
/
GetKeyChar.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; Link: https://autohotkey.com/board/topic/110808-getkeyname-for-other-languages/?p=682236
; Author: Lexikos
; Date:
; for: AHK_L
/*
Gui Add, Text, , Type a key name and click Convert.
Gui Add, Edit, vKeyName w50, vk4C
Gui Add, Button, Default, Convert
Gui Show
return
ButtonConvert:
Gui Submit, NoHide
MsgBox % "GetKeyName: " GetKeyName(KeyName)
. "`nGetKeyChar: " GetKeyChar(KeyName)
return
GuiClose:
GuiEscape:
ExitApp
*/
GetKeyChar(Key, WinTitle:=0){
thread := WinTitle=0 ? 0
: DllCall("GetWindowThreadProcessId", "ptr", WinExist(WinTitle), "ptr", 0)
hkl := DllCall("GetKeyboardLayout", "uint", thread, "ptr")
vk := GetKeyVK(Key), sc := GetKeySC(Key)
VarSetCapacity(state, 256, 0)
VarSetCapacity(char, 4, 0)
n := DllCall("ToUnicodeEx", "uint", vk, "uint", sc
, "ptr", &state, "ptr", &char, "int", 2, "uint", 0, "ptr", hkl)
return StrGet(&char, n, "utf-16")
}