Jump to content

1 Hotkey for 2 keys in pulse one-after-one


Recommended Posts

Hello, 

Looking for soultion,

want to prepare 1  Hotkey with 2 different options which would work one after one.

 

For example

 

HotKeySet('{F4}', 'functions')



Func functions()  ;// Pressing F4 1st time

    sleep(50)
    send("FirstPulse")
EndFunc


Func functions()  ;// Pressing F4 2nd time

    sleep(50)
    send("SecondPulse")
EndFunc

 

and 3rd time is again 1st, 

4th -> 2nd 

Link to comment
Share on other sites

Here's a way for you to do sequential actions through a single hotkey, expandable to more than just 2 options:

HotKeySet('\', 'fc') ; Keep in mind that Send can trigger hotkeys, so using '1' is a bad idea if you're Sending a 1 in your function

While True
    Sleep(10)
WEnd

Func fc()
    Local Static $iCount = 0
    Local Const $iCountMax = 5

    Switch $iCount
        Case 0 ; Keep in mind if you're starting at 0 or 1, and what you reset it to
            Send('Pulse 1')
        Case 1
            Send('Pulse 2')
        Case 2
            Send('Pulse 3')
        Case 3
            Send('Pulse 4')
        Case 4
            Send('Pulse 5')
        Case Else
            ConsoleWrite('Unregistered count/action: ' & $iCount & @CRLF)
    EndSwitch

    $iCount += 1
    If $iCount >= $iCountMax Then ; You can reset your count when you've reached your specified max
        $iCount = 0
    EndIf

    Return $iCount
EndFunc

 

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...