Jump to content

For..To loops and ImageSearch


 Share

Recommended Posts

I'm having a problem building a for.. to loop with a imagesearch inside

My code:

#include <ImageSearch.au3>
#RequireAdmin

Global $xfindsteps = 0
Global $yfindsteps = 0
$xdef = 0
$ydef = 0
Sleep(2000)

If _ImageSearchArea("C:\Users\Ricardo\Desktop\RealFont\Steps.png", 0, 270, 223, 307, 232, $xfindsteps, $yfindsteps, 0) = 1 Then
   MsgBox(0,"","Encontrou")
Else
   MsgBox(0,"","Nada")
EndIf

$novo_x = $xfindsteps - 8
$novo_x2 = $xfindsteps - 14

;;HERE BELOW, I GOT THE PROBLEM

For $i = 9 To 0
If _ImageSearchArea("C:\Users\Ricardo\Desktop\RealFont\" & $i & ".png", 0, $novo_x2, 223, $novo_x, 232, $xdef, $ydef, 0) = 1 Then $res = $i
Next

MsgBox(0,"",$res)

So, when i use this code, the last MsgBox() doesn't even appear. The script simply exits after the first MsgBox.

But if instead of a "For" loop i do this:

If _ImageSearchArea("C:\Users\Ricardo\Desktop\VIRTUADOPT\RealFont\5.png", 0, $novo_x2, 223, $novo_x, 232, $xdef, $ydef, 0) = 1 Then $res = 5

MsgBox(0,"",$res)

The MsgBox works and retrives the "5" that i'm expecting..

What did i wrong?

Edited by karudish
Link to comment
Share on other sites

Oh man.. I feel so ashamed but the mistake was indeed on the "Step" parameter :\

I don't know why it worked this time, i must have typed wrong or smth.. I need to rest before continuing on this xD

Thanks both of you :) <3

Btw, i didnt get anything from ConsoleWrite now i know its from RequireAdmin. My imagesearch.au3 also has "#RequireAdmin" so it doesnt matter if i really take it off on the script, cause the one i need to delete its on the included file.

Again thanks very much for both xD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...