Code: Select all
GetKeyboardInput(SpecificModifiers:=false) {
ih := InputHook()
ih.KeyOpt("{All}", "ES") ;End Keys & Suppress
ih.KeyOpt("{LCtrl}{RCtrl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}", "-ES") ;Exclude the modifiers
ih.Start()
ih.Wait()
if SpecificModifiers
Return KeyboardInput := ih.EndMods . ih.EndKey
NeutralModifiers := RegExReplace(ih.EndMods, "[<>](.)(?:>\1)?", "$1")
Return KeyboardInput := NeutralModifiers . ih.EndKey
}
#q::
KeyboardInput := GetKeyboardInput()
if (KeyboardInput = "Escape")
Exit
else if (KeyboardInput = "t")
MsgBox, t
else if (KeyboardInput = "^t")
MsgBox, ^t
else if (KeyboardInput = "!t")
MsgBox, !t
else if (KeyboardInput = "+t")
MsgBox, +t
else if (KeyboardInput = "#t")
MsgBox, "Not working if hotkey is already defined"
else if (KeyboardInput = "^#t")
MsgBox, ^#t
return
t::MsgBox, 1
^t::MsgBox, 2
!t::MsgBox, 3
+t::MsgBox, 4
#t::MsgBox, 5
^#t::MsgBox, 6