Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hk(keyboard:=0, mouse:=0, message:="", timeout:=3, displayonce:=0) {
- static AllKeys, z, d
- AllKeys := ""
- z:=message
- d:=displayonce
- For k,v in AllKeys {
- Hotkey, *%v%, Block_Input, off ; initialisation
- }
- if !AllKeys {
- s := "||NumpadEnter|Home|End|PgUp|PgDn|Left|Right|Up|Down|Del|Ins|"
- Loop, 254
- k := GetKeyName(Format("VK{:0X}", A_Index))
- , s .= InStr(s, "|" k "|") ? "" : k "|"
- For k,v in {Control:"Ctrl",Escape:"Esc"}
- AllKeys := StrReplace(s, k, v)
- AllKeys := StrSplit(Trim(AllKeys, "|"), "|")
- }
- ;------------------
- if (mouse!=2) ; if mouse=1 disable right and left mouse buttons if mouse=0 don't disable mouse buttons
- {
- For k,v in AllKeys {
- IsMouseButton := Instr(v, "Wheel") || Instr(v, "Button")
- Hotkey, *%v%, Block_Input, % (keyboard && !IsMouseButton) || (mouse && IsMouseButton) ? "On" : "Off"
- }
- }
- if (mouse=2) ;disable right mouse button (but not left mouse)
- {
- ExcludeKeys:="LButton"
- For k,v in AllKeys {
- IsMouseButton := Instr(v, "Wheel") || Instr(v, "Button")
- if v not in %ExcludeKeys%
- Hotkey, *%v%, Block_Input, % (keyboard && !IsMouseButton) || (mouse && IsMouseButton) ? "On" : "Off"
- }
- }
- if d
- {
- if (z != "") {
- Progress, B1 ZH0, %z%
- SetTimer, TimeoutTimer, % -timeout*1000
- }
- else
- Progress, Off
- }
- Block_Input:
- if (d!=1)
- {
- if (z != "") {
- Progress, B1 ZH0, %z%
- SetTimer, TimeoutTimer, % -timeout*1000
- }
- else
- Progress, Off
- }
- Return
- TimeoutTimer:
- Progress, Off
- Return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement