ImageSearch in a loop.

Get help with using AutoHotkey and its commands and hotkeys
Holis
Posts: 2
Joined: 19 Dec 2016, 15:29

ImageSearch in a loop.

19 Dec 2016, 15:43

I'm trying to write a script to scan a website for links and save them into an excel spreadsheet for me. So far i haven't done any loops and the program can login and create the correct search parameters... anyway long story short.
THIS is my first attempt at a loop.

Sleep 5000
x=0
while x < 1 imagesearch Zx, Zy, 189, 304, 780, 352
P:\Users\blahblahblah\Desktop\pics4program\The picture.bmp

iF ErrorLevel SendEvent down SendEvent down
Else
X+1
MouseMove, Zx ,Zy
Sleep 700
Click

Error at line 3:
P:\Users\blahblahblah\Desktop\pics4program\The picture.bmp
The leftmost character above is illegal in an expression

I am a complete and utter noob. I bow to the great forum gods and offer this smilee emoji as a token of my apprectiation. :)
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: ImageSearch in a loop.

19 Dec 2016, 16:06

Try this:

Code: Select all

Sleep 5000
x:=0 ; it's often better to use the assign operator and leave = for comparing values
while x < 1
{
imagesearch, Zx, Zy, 189, 304, 780, 352, P:\Users\blahblahblah\Desktop\pics4program\The picture.bmp
If ErrorLevel
{
SendEvent {down 2}
}
else
{
x++
MouseMove, Zx, Zy
Sleep 700
Click
}
}
return
Notice Blocks and keeping things on the right lines. If you want your ImageSearch broken up on two lines, you can do

Code: Select all

imagesearch, Zx, Zy, 189, 304, 780, 352
, P:\Users\blahblahblah\Desktop\pics4program\The picture.bmp
As a comma as the first character tells AHK to treat that as a continuation of the previous line.
Guest

Re: ImageSearch in a loop.

19 Dec 2016, 18:39

hey thanks a lot. I have very little coding education and am just kind of stumbling through. But yeah I see how keeping everything neat makes things less prone to bug.

Return to “Ask For Help”

Who is online

Users browsing this forum: bandel_nation, Google [Bot] and 40 guests