Jump to content
cherrylatte

Making While loop

Recommended Posts

cherrylatte

Hi

I just started studying Autoit and I am having trouble in understanding while loop statement.

I'm trying to make a script that is intended to go to another site when Image 'a.bmp' is exposed. The image 'a.bmp' will be a favicon of a certain site.

So the script below is made to perceive favicon 'a.bmp'

$search = _ImageSearch('a.bmp',0,0,0,0)
   While $search = _ImageSearch('a.bmp',0,0,0,0)
      Sleep(10)
   WEnd

This script actually works fine. It exits the loop and do the next action when 'a.bmp' appears. But the problem is that I've realized later on that the while loop is executed when the expression ( $search = _ImageSearch('a.bmp',0,0,0,0) is 'true'.

if the definition of while loop I've mentioned is correct, isn't the loop above should go through an infinite loop when the 'a.bmp' appears?

I'm so confused. I'd appreciate it if anyone answers..

Edited by cherrylatte

Share this post


Link to post
Share on other sites
Jfish

You are testing your condition twice.  The first $search is superseded by the second.  The second $search is in your while loop and when it becomes false it exits the loop (i.e. when the image detected changes so it is no longer 'a.bmp,0,0,0,0').  Delete the first line and run it again to see what happens.  Should be the same result.  If you explain what you are trying to do folks could offer suggestions.

  • Like 1

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


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

×