Hikari
Hikari

Reputation: 3947

AutoHotKey: send Ctrl+V inside of itself without recursiving

I have this script, when I press Ctrl+Win+Z it runs a Paste (Ctrl+V), then if ScrollLock is enabled it flushes Clipboard, deleting the content I just pasted.

^#A::
    Send ^v
    if GetKeyState("ScrollLock", "T"){
        Clipboard = 
    }
    Return

Now I wanna bind this command to Ctrl+V itself. But when I do so, I receive a dialog saying that "71 hotkeys have been received in the last 1092ms" and asking if I wanna continue.

I believe it's recursiving on itself. Every Send ^v triggers the command again.

How can I do that work? I don't want the clear clipboard to be in another shortcut, because I might forget to use this other shortcut and use Ctrl+V instead. I wanna use standard Ctrl+V for pasting and ScrollLock to set when clipboard should be flushed after it.

Upvotes: 0

Views: 1209

Answers (1)

phil294
phil294

Reputation: 10892

The $ prefix prevents hotkeys from triggering themselves:

$^v:: ; ....

Upvotes: 1

Related Questions