Help me understand what the syntax of this code means

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 me understand what the syntax of this code means

20 Sep 2020, 13:27

I have no Idea what the syntax of this code is saying.

Code: Select all

~]::
SetTimer RBracket,% (RBracket:=!RBracket)?12500:"Off"
I was told this works like a loop that repeats a task every 12.5 seconds, but what I don't understand is the ",%" and the "?" used in the code. I read the SetTimer notes and there is no information about this. I want to understand this code so that I can modify it and make a better code; I am trying to make a code that does the following:

~]::
press MButton and wait 12.5 seconds
if ] is pressed again at anytime between the 12.5 second of wait, then press MButton and reset timer (so that the next ~]:: will press MButton and wait 12.5 seconds), However, if ] is not pressed, then wait the whole 12.5 seconds

The code that almost does the job is this:

Code: Select all

~]::
SetTimer RBracket,% (RBracket:=!RBracket)?12500:"Off"
IF !RBracket
	return
RBracket:
	sendinput, {MButton down}
	sleep, 50
	sendinput, {MButton up}
return
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Help me understand what the syntax of this code means

20 Sep 2020, 17:05

mexican scientist wrote:
20 Sep 2020, 13:27
I have no Idea what the syntax of this code is saying.

Code: Select all

~]::
SetTimer RBracket,% (RBracket:=!RBracket)?12500:"Off"
This is like an If/ else statement but in a single line that switches between the two options using a variable that switches between two states (True & False).

An example here.

Code: Select all

F1::MsgBox, % (Toggle := !Toggle) ? "First Option" : "Second option"
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 150 guests