Auto it: Loop problem and delay issue.

11/01/2012 07:08 logical691#1
Ok i will star tof by saying im a noob at this but have been playign with auto it on and off for the past week or so, mainly to see how much i could do and ive done abit code wise but loops always seem to confuse me, specially when im needing an array too.

Anyway i'll try and explain the best i can.
The code below is to search for an image, one the image is found it contines with more code, what i would like to do is make it so that "if" it does not find the image its looking for it checks for an alternative image example: "warehouse1.png|warehouse2.png|warehouse3.png" this is what i have so far but it will not loop though images in my tests.

Code:
$img = "t"
$FileList = _FileListToArray($path, "*.png", 1)

For $i = 1 to $FileList[0]
	$array = StringSplit($FileList[$i],"|")
	$image = $array[1]
	;ConsoleWrite($img & @CRLF)
	$img = _ImageSearchArea($image, 1, 0, 0, @Desktopheight, @DesktopWidth, $x, $y, 100)
	MsgBox(0,"",$image & @crlf & "coords are: " & $X & "," & $Y)
	MouseMove($x,$y)
	sleep(1000)
	;ConsoleWrite($img & @CRLF)
Next
Second lot im just confused with how i would do it so many someone can help. Basically i want the code to run to a certain point and then "search" for an image before proceeding further, so far though all i ahve had is the code running in a loop repeating actions:

Code:
Func DoInstance()
	logfile("Setting up instance")
	ConsoleWrite("Setting up instance")
	MouseClick ("left", 500 , 608)
	sleep(Random(1000,1500))
	MouseClick ("left", 490 , 660)
	sleep(Random(1000,1500))
	MouseClick ("left", 290 , 580)
	sleep(Random(1000,1500))
	MouseClick ("left", 700 , 440) 
	sleep(Random(1000,1500))
	logfile("Selecting fleets")
	ConsoleWrite("Setting up fleets")
	call("fleet")
	logfile("Starting instance")
	ConsoleWrite("Starting instance")
	MouseClick ("left", 700 , 380); OK
    sleep(Random(1000,1500))
	logfile("End of instance")
	ConsoleWrite("End of instance") ; <====== need the code to stop here and wait till image below is found before restarting the loop
	$img = _ImageSearchArea($pngLoc & "close.png", 1, 0, 0, @Desktopheight, @DesktopWidth, $x, $y, 100)
	If $img = True Then
		logfile("collecting mail")
		ConsoleWrite("collecting mail")
	call ("mail")
EndIf
Hope this amde sens and if not sorry :/
11/01/2012 13:02 Imaginär#2
Why StringSplit($FileList[$i],"|")?
According to [Only registered and activated users can see links. Click Here To Register...] you should be able to just use $FileList[$i].

_ImageSearchArea() does not return a boolean on success. It's actually an array with x and y coordinates.
-> If IsArray($img) ...
--> X-Coord: $img[0] // Y-Coord: $img[1]

If you want to store the certain value of the array on another var, you better use $image = $array[$i], instead of $image = $array[1].
11/02/2012 04:14 logical691#3
Thanks for the reply Imaginar, i used it because it was from code i saw if im honest. So thught it was needed if not then when i look at the script again i will remove it.

As for your other answer i'll have a play when i open up the script again. Like i said im new to all this and arrays, loops and what not confuse me lol i just want to cut the code down and improve it a little.

Thansk for your time and like i said soon a i get hance i'll play about =)
11/04/2012 11:05 logical691#4
Nope not getting anywhere :/

Code:
Global $x = 0
Global $y = 0
MsgBox(0,"","script started")

$path = "incs\"
$num = "2"

$FileList = _FileListToArray($path, "instance" & $num & "*.png", 1)

For $i = 1 to $FileList[0]
	$array = $FileList[$i]

	$img = _ImageSearchArea($array, 1, 0, 0, @Desktopheight, @DesktopWidth, $x, $y, 100)
	MsgBox(0,"",$array & @crlf & "coords are: " & $x & "," & $y) ; display files name no cords
sleep(1000)

	if IsArray ($FileList) Then
		msgbox (0,"","array stuff")
		MsgBox (0,"",$FileList[1])
		$img = _ImageSearchArea($FileList[1], 1, 0, 0, @Desktopheight, @DesktopWidth, $x, $y, 100)
		MsgBox(0,"",$FileList[1] & @crlf & "coords are: " & $FileList[2] & "," & $Y) ;$filelist[2] fails
	EndIf