Jump to content

For..To loops and ImageSearch

Recommended Posts

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

My code:

#include <ImageSearch.au3>

Global $xfindsteps = 0
Global $yfindsteps = 0
$xdef = 0
$ydef = 0

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

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


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


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


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

What did i wrong?

Edited by karudish
Link to post
Share on other sites

Actually just run your script, you need to declare $res, i.e. Global $res at the top of your script, also noticed you're using #RequireAdmin which means that you don't see anything in the console, so you would need to use MsgBox to debug.

Link to post
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...