Code: Select all
Procedure.l HotKeyStringToCode(HotKey$)
Protected ModKey
HotKey$ = ReplaceString(HotKey$ , " " , "")
If FindString(HotKey$, "Ctrl+", 1, #PB_String_NoCase)
ModKey | #MOD_CONTROL
EndIf
If FindString(HotKey$, "Alt+", 1, #PB_String_NoCase)
ModKey | #MOD_ALT
EndIf
If FindString(HotKey$, "Shift+", 1, #PB_String_NoCase)
ModKey | #MOD_SHIFT
EndIf
Debug Right(HotKey$, 1)
ModKey | (Asc(Right(HotKey$, 1)) | $FF)
ProcedureReturn ModKey
EndProcedure
Define HotKey$ = "Ctrl + Alt + F"
ini_HotkeyCode = HotKeyStringToCode(HotKey$)
Debug ini_HotkeyCode
Define HotKey$ = "Ctrl +J"
ini_HotkeyCode = HotKeyStringToCode(HotKey$)
Debug ini_HotkeyCode
; ===============================
If ini_HotkeyCode
Debug ini_HotkeyCode
VirtKey = ini_HotkeyCode & $FF ; LoWord
ModKey = GetModKey(ini_HotkeyCode >> 8)
Debug GetKey(ini_HotkeyCode)
UnregisterHotKey_(hWnd_0, #HK_ID) ; reassignment works without unregistration
If Not RegisterHotKey_(hWnd_0, #HK_ID, ModKey, VirtKey)
MessageRequester("Error", "Failed to register hotkey")
EndIf
EndIf