How to break this sequence on a new same input?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
swagmaster143
Posts: 3
Joined: 09 Jun 2023, 12:33

How to break this sequence on a new same input?

Post by swagmaster143 » 09 Jun 2023, 12:42

How can I make it so that if I press LButton again while RButton is being sent? Basically break and restart the loop when LButton is pressed again.

Code: Select all

LButton::
sleep 1
Send {RButton down}
Sleep 150
Send {RButton up}
return
[Mod edit: [code][/code] tags added.]

[Mod edit: Moved topic to AHK v1 help, based on the posted code (not v2!).]

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to break this sequence on a new same input?

Post by mikeyww » 09 Jun 2023, 12:53

Welcome to this AutoHotkey forum!

I do not see a loop. What loop do you mean?

swagmaster143
Posts: 3
Joined: 09 Jun 2023, 12:33

Re: How to break this sequence on a new same input?

Post by swagmaster143 » 09 Jun 2023, 13:23

i want to make a loop

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to break this sequence on a new same input?

Post by mikeyww » 09 Jun 2023, 14:02

I do not understand. If you press the button a second time, then the subroutine will execute a second time. You have not fully explained what the script should do.

swagmaster143
Posts: 3
Joined: 09 Jun 2023, 12:33

Re: How to break this sequence on a new same input?

Post by swagmaster143 » 10 Jun 2023, 08:43

Sorry for the poor explanation I am new to AHK. I checked other forum posts and was able to fix my problem. I was trying to reach this end result:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#MaxThreadsPerHotkey, 255

LButton::
SetTimer, Timer_1, Off
counter:=0
SetTimer, Timer_1, -25
return

Timer_1:
counter++
If counter=1
{
Send {RButton down}
SetTimer, Timer_1, -175
}
else if counter=2
{
Send {RButton up}
SetTimer, Timer_1, Off
}

return




*F2::
Suspend ;Suspend Hotkeys off/on
Pause,, 1 ;Pause Script off/on

Post Reply

Return to “Ask for Help (v1)”