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 := ["4", "3", "1","2", "5", "`"]
- ; Init lookup array for modifiers
- modifiers := {LAlt: 0, LShift: 0, LCtrl: 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.LAlt || modifiers.LCtrl || modifiers.LShift){
- modifier_held := 1
- } else {
- modifier_held := 0
- }
- s := ""
- ; Build the list of modifiers to use for the send
- if (modifiers.LAlt){
- s .= "!"
- }
- if (modifiers.LShift){
- s .= "+"
- }
- if (modifiers.LCtrl){
- s .= "^"
- }
- ; Send the key with the modifiers
- Send % s "{" key "}"
- }
- }
- Sleep 1
- }
- ; 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
- $~*LAlt::
- $~*LShift::
- $~*LCtrl::
- mod := substr(A_ThisHotkey, 4)
- modifiers[mod] := 1
- return
- $~*LAlt up::
- $~*LCtrl up::
- $~*LShift up::
- mod := substr(A_ThisHotkey, 4)
- ; Remove " up" from end
- mod := substr(mod, 1, StrLen(mod) - 3)
- modifiers[mod] := 0
- return
- ; Quit script on F6
- ;*** Suspend AHK ***
- ~F5::Suspend
- F6::
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement