How to set the same shortcut (e.g. #s) to send one command when single pressing, and another when pressed twice?

Discussion, questions and support.
Post Reply
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Feb 21st, ’20, 13:19

Hi,

I'd appreciate your assistance.
The script below works properly when it is run as a native AHK script, allowing to set the same shortcut (e.g. #s) to send one command when single pressing, and another when pressed twice.
I tried to implement this script into Fastkeys as a shortcut and a start menu item, being unsuccessful with my implementation in both cases.
How can I run such a script from Fastkeys?

Thank you!
Carlos

Code: Select all

#MaxThreadsPerHotkey, 2

KeyPress := 0, running := False

#s::
    KeyPress++

    If (running = True) {
        Return
    }

    running := True

    While (A_TimeSinceThisHotkey < 300) {
        If (KeyPress > 1) {
            MsgBox, Two times

            KeyPress := 0, running := False
            Return
        }
    }

    MsgBox, One time

    KeyPress := 0, running := False
Return
User avatar
Marko
Posts: 1726
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Feb 21st, ’20, 17:26

I suggest using Type: Script for scripts like this. You can run it automatically by using a Start menu with "Run on startup" option.
Post Reply