Code: Select all
CoordMode, ToolTip, Screen
SetFormat, IntegerFast, H
HtKey:= "~Esc" ; Change Esc if it interferes with your Hotkey (e.g. F1-F12, Del, Ins, etc.) or ↓
; when running the sript double press this Hotkey to input new one!
CleanTimer := -3000 ; Must be a negative number (the timer will run only once)
gosub, GetKeyVKSC
;~ Loop, 5000
Loop, 255
{
if GetKeyName(Format("vk{:x}", a_index - 1)) {
Hotkey, % "~*" GetKeyName(Format("vk{:x}", a_index - 1)), GetText
Hotkey, % "~*" GetKeyName(Format("sc{:x}", a_index - 1)), GetText
}
}
; "~" keeps the button original function
; "*" fires the hotkey even if extra modifiers are being held down
Gui, New, -MinimizeBox +hwndHw
Gui, Color, 0xd0c060, 0x666666
Gui, Font, s14 cffff00 TAhoma
Gui, Add, Edit, w180
Gui, Show
GroupAdd, GuiDisp, ahk_id %Hw%
Return
GetText:
if !Active
Return
SetTimer, CleanText, Off
Sleep, 50
Key := RegExReplace(A_ThisHotkey, "^..") ; "^.." removes the first 2 characters ("~*") from the returned string
KeyVK := GetKeyVK(Key)
KeyVK := RegExReplace(KeyVK, "^..")
KeySC := GetKeySC(Key)
KeySC := RegExReplace(KeySC, "^..")
Text .= Key " "
;~ ToolTip, % Data:="Key Name: {" Key "}`r`nKey VK: {vk" KeyVK "}`r`nKey SC: {sc" KeySC "}`r`n`r`n" Text, 0, 0 ; X\Y coordinates
ToolTip, % Data:=Text
Data2.= Data ; "`r`n---------------------`r`n"
GoSub GetKeyVKSC
SetTimer, CleanText, %CleanTimer%
Return
CleanText:
Text := ""
ToolTip
Return
GuiClose:
ExitApp
Return
GetKeyVKSC:
If Active {
Active:=False
ControlSetText, Edit1, % " " LTrim(Data2, "RL") "+ ", ahk_id %Hw%
ControlSend, Edit1, {End}, ahk_id %Hw%
Data:=Data2:=""
ToolTip
} else {
Active:=True, Data:="" ;Data2:="---------------------`r`n",
ControlSetText, Edit1, % "", ahk_id %Hw%
Hotkey, IfWinActive, ahk_group GuiDisp
Hotkey, % HtKey, GetKeyVKSC
Hotkey, IfWinActive
}
Return