Creating a Toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
edc
Posts: 26
Joined: 17 Jun 2021, 16:23

Creating a Toggle

17 Jun 2021, 16:37

Hello,
I'm looking to create a toggle hotkey. I would like to press F5 and then have a sequence of mouse clicks (3 clicks) then I would like to press F5 again and have it perform another sequence of mouse clicks (3 clicks). Is this possible?

Once F5 has been pressed 2 times, it would start over when pressed for the 3rd time.

Code: Select all

f5::
{
coordmode, mouse, screen
mouseclick, left, 573, 389
sleep, 100
mouseclick, left, 520, 324
sleep, 100
mouseclick, left, 520, 324
sleep, 100
}        
keywait, f5
{
coordmode, mouse, screen
mouseclick, left, 1499, 769
sleep, 100
mouseclick, left, 1542, 767
sleep, 100
mouseclick, left, 523, 382
sleep, 100
}
return
Thanks!
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Creating a Toggle

17 Jun 2021, 17:03

An example is below.

Code: Select all

F5::
CoordMode, Mouse
If on := !on {
 SoundBeep, 1500
 Click, 573 389
 Sleep, 100
 Click, 520 324
 Sleep, 100
 Click, 520 324
} Else {
 SoundBeep, 1000
 Click, 1499 769
 Sleep, 100
 Click, 1542 767
 Sleep, 100
 Click, 523 382
}
Return
Another way:

Code: Select all

F5::
CoordMode, Mouse
If on := !on
     clik( 573, 389), clik( 520, 324), clik(520, 324)
Else clik(1499, 769), clik(1542, 767), clik(523, 382)
Return

clik(x, y) {
 MouseClick,, x, y
 Sleep, 100
}
edc
Posts: 26
Joined: 17 Jun 2021, 16:23

Re: Creating a Toggle

17 Jun 2021, 17:09

Just what I needed.

Thank You!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Decar, doodles333, mikeyww and 227 guests