Help with a few subjects

Get help with using AutoHotkey and its commands and hotkeys
Noam527
Posts: 83
Joined: 08 Aug 2016, 17:20

Help with a few subjects

09 Aug 2016, 18:04

just as the title says...:
1) what do these mean and do?:
.=
:=
!=
(If there are more, include them in the answer please)
When should these be used?

2) Let's say I want the script to pause itself until my A_cursor is on IBeam.
So I thought about this thing:

<start of the script here>

Loop
{
If A_cursor = IBeam
{Break}
}

<end of the script here>

So two questions about what I typed up here:
I) How do I type the bolded line correctly? (so it will actually check if the cursor is on IBeam "mode")
II) Is there any way to shorten/optimize that script?

3) Is there any command (or anything I can make) that tells the script-reading to return to a certain line?
So I can type something like:

if <expression>
ReturnTo 13 ; return to line 13.


Any help is great!
J Richards
Posts: 8
Joined: 01 Dec 2014, 15:07

Re: Help with a few subjects

09 Aug 2016, 19:43

1)
.= - I have no idea, maybe someone can fill us in.
:= - Dunno what it's called, an expression operator? Basically it expects an expression on the right.

var = cheese ; var contains a string, "cheese"
var := "cheese" ; var contains a string, "cheese"
var := cheese ; var is assigned the contents of cheese. If cheese were a variable with a number, say 5, then var would contain a "5"

!= - not equals

if (cheese != 5)
msgbox cheese isn't five!

2)
Loop
{
If (A_cursor = "IBeam")
Break
sleep 50 ; script waits 0.05 seconds before continuing
}

That work? Untested.

3)
Lables, unless you're inside a function.

DoThis:
var += 1
if (var < 10)
Goto DoThis
NowDoThis:
var2 += 10
if (var2 < 100)
Goto NowDoThis
MsgBox var is at least ten (%var%) and var2 is at least one hundred (%var2%).
return


Hope I got that right.
Noam527
Posts: 83
Joined: 08 Aug 2016, 17:20

Re: Help with a few subjects

09 Aug 2016, 20:35

J Richards wrote:1)
.= - I have no idea, maybe someone can fill us in.
:= - Dunno what it's called, an expression operator? Basically it expects an expression on the right.

var = cheese ; var contains a string, "cheese"
var := "cheese" ; var contains a string, "cheese"
var := cheese ; var is assigned the contents of cheese. If cheese were a variable with a number, say 5, then var would contain a "5"

!= - not equals

if (cheese != 5)
msgbox cheese isn't five!

2)
Loop
{
If (A_cursor = "IBeam")
Break
sleep 50 ; script waits 0.05 seconds before continuing
}

That work? Untested.

3)
Lables, unless you're inside a function.

DoThis:
var += 1
if (var < 10)
Goto DoThis
NowDoThis:
var2 += 10
if (var2 < 100)
Goto NowDoThis
MsgBox var is at least ten (%var%) and var2 is at least one hundred (%var2%).
return


Hope I got that right.
Thanks, you've solved a lot of my questions! but few are unsolved...
Oh by the way, you typed: "var +=1"
Does it mean that var is at least 1?
J Richards
Posts: 8
Joined: 01 Dec 2014, 15:07

Re: Help with a few subjects

09 Aug 2016, 20:52

var += 1 increments by one, the same thing as var++ and var := var + 1

Except, var := var + 1 doesn't seem to work if var is empty. So you'd have to make sure it wasn't empty beforehand. var = 0
TAC109
Posts: 550
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Help with a few subjects

09 Aug 2016, 21:16

For information on .= etc., read up on this subject in the help file. Scroll down to 'assign' in the table, although the whole page is worth a read.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: Help with a few subjects

09 Aug 2016, 21:18

Hi, look here:

https://autohotkey.com/docs/Variables.htm#Operators


All your questions are answered there.
hunter99
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Help with a few subjects

10 Aug 2016, 13:22

For question 1, see the link provided by TAC109 and Hunter99.

For question 2, there are several possible methods. Here are two of them...

Code: Select all

; Method 1
Loop {    ; This curly brace...
	If A_cursor = IBeam
		Break    ; The Break command does not get wrapped in curly braces.
}    ; ... and this one are optional, since the "If A_cursor = IBeam" line is the only line being processed in the loop.


; Method 2
While A_Cursor != "IBeam"
	Continue
For question 3, Labels combined with GoTo are the closest option. GoSub can also be quite useful. :)

Return to “Ask For Help”

Who is online

Users browsing this forum: anhnha, Bing [Bot], Chunjee, Google [Bot], littlegandhi1199, RubbeH, sobuj53, TAC109, VibinonAHk, Xeo786 and 42 guests