Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kb := new AllKeyBinder(Func("KeyEvent"), "*")
- return
- KeyEvent(code, name, state) {
- static PreventSwitch := "", Toggle := ""
- if (name != "LWin") {
- if (GetKeyState("LWin", "P") && state) {
- PreventSwitch := 1
- if (name = "Numpad2")
- Run, Explorer.exe
- else
- Sendinput {LWin Down}
- }
- Sendinput, % "{Blind}{"name (state ? " Down}" : " Up}")
- }
- else {
- if state
- PreventSwitch := 0
- else
- Sendinput, % PreventSwitch ? (GetKeyState("LWin") ? "{LWin Up}" : "") : ("#^{"((Toggle:=!Toggle) ? "Left}" : "Right}"))
- }
- }
- class AllKeyBinder{ ; By evilC
- __New(callback, pfx := "~*"){
- keys := {}
- this.Callback := callback
- Loop 512 {
- i := A_Index
- code := Format("{:x}", i)
- n := GetKeyName("sc" code)
- if (!n || keys.HasKey(n))
- continue
- keys[n] := code
- fn := this.KeyEvent.Bind(this, i, n, 1)
- hotkey, % pfx "SC" code, % fn, On
- fn := this.KeyEvent.Bind(this, i, n, 0)
- hotkey, % pfx "SC" code " up", % fn, On
- }
- }
- KeyEvent(code, name, state){
- this.Callback.Call(code, name, state)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement