Can Someone Help Me With Array Functions? and Other Stuff.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tikitree
Posts: 3
Joined: 27 Aug 2016, 04:11

Can Someone Help Me With Array Functions? and Other Stuff.

17 Jul 2018, 02:55

Hello one and all. I am not really new to Autohotkey, but I still have no idea what I am doing, and have little to no programming knowledge to help me learn.

Context:
I have been working on a script to look at a web page and using ImageSearch find all check boxes and click them. when I was looking around at what people do for fining multiple images, I found this forum post here https://autohotkey.com/board/topic/4603 ... -question/, the wonderful code provided by 'jethrow' works ridiculously fast, finding all the coordinates of the check boxes in a fraction the time of any other solution I have seen yet. However aside from displaying them in a message box I have no idea how to get at said coordinates for mouse move commands, and despite spending a couple hours trying to understand his code i am just too far out of my elements to figure it out.

Never the less I have a few questions:
-First, is anyone able to explain just what each part of this code actually does?? I really want to understand it, but I am just so confused by it.

-Second, after all the points are saved into the array, is it possible to take the first set of coordinates, save it to a variable, do a couple tasks off with those points as variables, then delete it from the array before moving on to the next set of coordinates, and repeating until the array is empty?



Hope you can help me.

Code In Question, \/ *Not made by me, all credit goes to jethrow for this.* \/

Code: Select all

CoordMode, Mouse, screen
CoordMode, Pixel, screen
Xo:=Yo:=0, list:=""
Loop, {
	ImageSearch, x, y, %Xo%, %Yo%, %A_ScreenWidth%, %A_ScreenHeight%, % A_Desktop "\box.bmp"
	If InStr(list, x "," y "`n") {
		Xo := x+1
		Continue
	}	
	If(x="" || y="")
		If Xo {
			Xo := 0, Yo := Yo+1
			Continue
		} Else Break
	list .= x "," y "`n", Yo := y
}
MsgBox, %list%
Freire
Posts: 16
Joined: 10 Dec 2017, 11:30

Re: Can Someone Help Me With Array Functions? and Other Stuff.

17 Jul 2018, 13:45

The code you quoted will perform the "ImageSearch" function for pixels in the Horizontal and then in the Vertical. It will progress pixel by pixel in each direction in order to read all possible Image matches.
The variables Xo and Yo are the ones that drives this behaviour.
The variables x and y are the ones with the location of the current match, they will be then concatenated to the list and there is a check to not add duplicates with the "InStr()" function.

If you want to do things with each found box:

Code: Select all

list .= x "," y "`n" ;Replace this line with what you want. E.G.: MouseClick, left, %x%, %y%
Yo := y ;Keep this line
tikitree
Posts: 3
Joined: 27 Aug 2016, 04:11

Re: Can Someone Help Me With Array Functions? and Other Stuff.

17 Jul 2018, 22:13

Thank you so much Freire, although I still don't understand what a lot of the functions do, I now do understand how that code works more or less.

also your recommendation worked well, and I was able to preform the clicks I needed, however when I started using more complicated page layouts the code has started to miss and not record the points of certain boxes. so sadly I am back to square one, and am going to start over.

Thanks again for your help.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Ineedhelplz, Spawnova and 326 guests