SpaceBroetchen
SpaceBroetchen

Reputation: 21

AHK Send Keys which are as Key defined

I have a problem while using a Hotkey from Ahk. Im using this code to activate if activated = 1 a piece of code


    l::
         if (activated = 1)
         {
              send, Hello there
         }
    else
        send, l

The problem is if activated = 0 the l key wont press because itactivate it self. Have anyone an idea how to solve it? thanks SpaceBroetchen

Upvotes: 0

Views: 1183

Answers (1)

0x464e
0x464e

Reputation: 6499

The $ prefix(docs) is meant for this.
Makes it so the hotkey wont self trigger.
Also, I'd recommend SendInput, it's the faster and more reliable send mode.

$l::
    if (activated = 1)
        SendInput, Hello there
    else
        SendInput, l
return

Though, seems like an even better option would be to use a context sensitive hotkey for this.
If you want to tell me more about this activated check, I can probably recommend a better approach for this.

Upvotes: 2

Related Questions