Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; To add a new key to the script, add it to this array:
- key_list := ["1", "2", "3", "4", "q", "e", "r", "t", "f", "v", "g", "z", "x", "c", "b"]
- ; Init lookup array for modifiers
- modifiers := {LShift: 0, LCtrl: 0, LAlt: 0}
- ; Build lookup array, declare hotkeys
- keys := {}
- keys_modded := {}
- Loop % key_list.MaxIndex(){
- key := key_list[A_Index]
- ; init array values
- keys[key] := 0
- keys_modded[key] := 0
- ; Declare hotkeys for up and down events
- hotkey, $*%key%, keydown
- hotkey, $*%key% up, keyup
- }
- Loop {
- ; Endless loop - always running
- for key, value in keys {
- ; Loop through each of the keys
- if (value){
- ; If the key is held...
- ; Detect if any modifiers held
- if (modifiers.LCtrl || modifiers.LShift){
- modifier_held := 1
- } else {
- modifier_held := 0
- }
- if (key = "q" && modifiers.LCtrl){
- ; Special case - CTRL + Q
- if (keys_modded[key]){
- ; We already sent a modded version of this key, then ignore
- ; keys_modded[key] will be set to 0 on up event of key
- continue
- } else {
- ; We are going to send a modded version of this key, set keys_modded[key] to 1, so it ignores next time
- keys_modded[key] := 1
- }
- }
- if (key = "g" && modifier_held){
- ; Special case - ANY modifier and g
- if (keys_modded[key]){
- continue
- } else {
- keys_modded[key] := 1
- }
- }
- ; Build the list of modifiers to use for the send
- s := ""
- if (modifiers.LShift){
- s .= "+"
- }
- if (modifiers.LCtrl){
- s .= "^"
- }
- ; Send the key with the modifiers
- Send % s "{" key "}"
- }
- }
- Sleep 20
- }
- ; Any of the "keys" (ie not modifiers) being pressed will call this
- keydown:
- key := SubStr(A_ThisHotkey,3)
- keys[key] := 1
- return
- ; Any of the "keys" being released will call this
- keyup:
- key := SubStr(A_ThisHotkey,3)
- ; Remove " up" from end
- key := substr(key, 1, StrLen(key) - 3)
- keys[key] := 0
- keys_modded[key] := 0
- return
- ; Modifiers
- $*LShift::
- $*LCtrl::
- mod := substr(A_ThisHotkey, 3)
- modifiers[mod] := 1
- return
- $*LCtrl up::
- $*LShift up::
- mod := substr(A_ThisHotkey, 3)
- ; Remove " up" from end
- mod := substr(mod, 1, StrLen(mod) - 3)
- modifiers[mod] := 0
- return
- Enter::
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement