Hello, im using script below for gaming, but i have problem with excluding modifier-key combination. I want to keep for example key “e” active, but exclude combination “ctrl + e”. Is it possible? Thank you in advance for your help.
; To add a new key to the script, add it to this array:
key_list := ["3", "e", "r", "q"]
; 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
}
; Build the list of modifiers to use for the send
s := ""
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 Escape
;*** Suspend AHK ***
~F1::Suspend
Esc::
ExitApp