Help with a code that I have created.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mexican scientist
Posts: 33
Joined: 02 Jul 2020, 21:55

Help with a code that I have created.

Post by mexican scientist » 06 Dec 2022, 18:46

Hi, I am very noob at this, I made a script that has this:

Code: Select all

$1::
sendinput, {numpad1 down}
sleep, 1000
sendinput, {numpad1 up}
sleep, 100
sendinput, {1 down}
sleep, 2000
sendinput, {1 up}
return

2::
SetTimer NumpadDiv,% (NumpadDiv:=!NumpadDiv)?200:"Off"
IF !RBraket
	return
NumpadDiv:
	sendinput, {1 down}
	sleep, 100
	sendinput, {1 up}
Return
The code does this: Key 2:: presses 1 on a loop, but when I press $1::, I want the first code to stop or pause what key #2 is doing. Any help?

So, basically i am asking for a solution in general. I want to know how can I stop or pause scripts for example if key 1 is press, stop script #2 running.

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

Re: Help with a code that I have created.

Post by mikeyww » 06 Dec 2022, 19:39

Code: Select all

NumpadDiv := False
SetTimer, NumpadDiv, Off

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Help with a code that I have created.

Post by boiler » 06 Dec 2022, 19:43

@mexican scientist — Did you name both a variable and a subroutine label “NumpadDiv” even though neither have anything to do with the keyboard key by that name just to make things extra confusing? And then why did you use a variable named RBraket not used anywhere else?

Post Reply

Return to “Ask for Help (v1)”