Jump to content
Sign in to follow this  
TheDingo

Problems getting cycle to end

Recommended Posts

TheDingo

I am having a slight issue getting a While - Do cycle to end when the condition is met. Also i am having a problem getting a sound to play.

HotKeySet("{ESC}", "Terminate")
While 1
    Do
        sleep(3000)
        MouseClick("left", 103, 212)
        Sleep(3000)
        MouseClick("left", 187, 709)
        Sleep(3000)
     Until PixelGetColor (011, 704) <> 0xFFFFFF
  WEnd
  SoundPlay(@WindowsDir & "\Users\Office\Desktop\watch for new email\sound\Alarm.wav", 1)
Func Terminate()
   Exit 0
EndFunc

Basically it should click one location on the screen, wait, then click another location on the screen until the pixel at (11,704) is white, then stop clicking and play the sound file.

Currently it will click, wait, click, but when the conditions is met ( until pixel get color ) it just continues on clicking away like the pixel was never white.

I know the grid coords and the color are correct as i coded a pixel grid coords and color checker and have used it before with no issues.

Could anyone please help me find the missing period, comma, quote, whatever it is i missed or messed up.

Thanks a bunch.

Share this post


Link to post
Share on other sites
TheDingo

Move the SoundPlay statement before your WEnd.

 

Ok, done that, but it still neither stops when the pixel turns white, nor plays the sound. I have looked the code over a dozen times and cannot seem to find where i went wrong. For 15 short lines of code this is sure turning out to be a headache.

Share this post


Link to post
Share on other sites
Danp2

You haven't given enough details for anyone to help you further. What program or process are you trying to automate? There may be a better way to accomplish this, but we won't know unless you provide additional details.

Share this post


Link to post
Share on other sites
TheDingo

There really are not any more details to be had, its an automated maual "find" search for a webmail client that receives a few thousand e-mails an hour.

The first click: clicks the next button to go to the next page

The second click click the up arrow on the firefox "find" bar (from when you hit ctrl+f)

The pixel get color checks the color of the find field text box, if the word is not found it is red, when the background turns white it means it found the search term

and once that is done it needs to stop.

Thats the best i can give you, i am not really looking for a better way to do it, my coding abilities are limited, and i am not one of those guys who is like "here, code this for me because i am lazy". I have code, it all appears to be right, but it is not working in the manner that the documentation of Autoit says it should work, so i am asking for someone to take a brief glance at 15 lines of code and tell me where i went wrong and why it is not stopping when the until pixelgetcolor condition is met, furthermore not playing the sound.

Thanks :)

Share this post


Link to post
Share on other sites
TheDingo

Nevermind, got the not stopping part fixed. i forgot to add EndLoop.

Now just to figure out how to get it to play a sound from a file thats not embedded.

Share this post


Link to post
Share on other sites
Danp2

There are definitely more reliable ways to automate Firefox.

As far as playing the sound, you may want to check the path you are passing to SoundPlay. Your setup may be unique, but I would say that most installs don't have a directory named "Users" beneath their Windows directory.

Share this post


Link to post
Share on other sites
somdcomputerguy

I have found the SoundPlay function to not always work, although that might be because the computer I use is a piece of crap.. You might have better luck with the Run or ShellExecute functions.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
Sign in to follow this  

×