Hello and thank you both for your help.
Adding
global and using just
KeyWait had a positive effect
I have one last wish regarding this topic.
My idea is that when I press a key for a short time (e.g. less than 200 ms), that it has its normal function.
This can be useful for keys like F11 or F12, where you normally don't hold these keys pressed.
While holding these keys, I would like to use them as modifiers.
The modifier thing works now, but I'm not sure how to achieve the short key press thing, yet I'm sure it can work.
Code: Select all
5::
Short_Long(func("Key_Normal").bind(A_ThisHotkey), func("Hold_Key").bind(A_ThisHotkey), A_ThisHotkey)
return
Short_Long(param1, param2, key) ; Works
{
KeyWait, %key%, T0.2 ; Prüfen, ob die Taste weniger als 200 ms lang gedrückt gehalten wurde
if ErrorLevel = 1 ; Skript 2 - Taste wurde lang gedrückt gehalten:
{
param2.(myObject) ; Taste lang gedrückt: Funktion 2
KeyWait, %key% ; Warten, dass die Taste erneut gedrückt wird
}
else ; Skript 1 - Taste wurde kurz gedrückt:
{
param1.(myObject) ; Taste kurz gedrückt: Funktion 1
}
}
Key_Normal(key) ; Doesn't work
{
global ; Probably no effect
;MsgBox, %key% ; MessageBox appears and shows correct key ("5" in this case)
Send {%key%} ; Key does not get sent
}
Hold_Key(key) ; Works perfectly
{
global
modifier := 1
KeyWait, %key% ; After key was released:
modifier := 0
}
#if modifier
4::
Send hello ; Works
return
6::
Send test ; Works
return
#if
Thanks again for any help and best regards