Page 1 of 1

Help with a code that I have created.

Posted: 06 Dec 2022, 18:46
by mexican scientist
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.

Re: Help with a code that I have created.

Posted: 06 Dec 2022, 19:39
by mikeyww

Code: Select all

NumpadDiv := False
SetTimer, NumpadDiv, Off

Re: Help with a code that I have created.

Posted: 06 Dec 2022, 19:43
by boiler
@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?