Sign in to follow this  
Followers 0
ttleser

While Loop help

7 posts in this topic

I want to create a simple program that will:

1. Hold the script until a certain color is at a certain pixel location and move the mouse and click at a certain location.

2. Then I want it to wait until a another window appears with "Blizzard Updater" in the title and "The update was successful." in the text.

I was able to get #1 working, but not continually wait until the color at that pixel location is "FFC700".

The problem with #2 is that a window that's titled "1% - Blizzard Updater" will appear and will download the update and the percentage in the window title will continually change until it says 100%. I need the second part of the script to be able to wait until it shows "100% - Blizzard Updater" then continue with the script.

Here's what I've got so far, thoughts?

$var = PixelGetColor( 622, 301)
$var1 = Hex($var,6)
While $var1 <> "FFC700"
    sleep(1000)
    MouseClick("left", 520, 443, 1)
WEnd
Opt("WinTitleMatchMode", 2)

While 1
    $var2 = WinExists("Blizzard Updater", "The update was successful.")
    If $var2 = 1 Then
        send("{ENTER}")
        sleep(10000)
        send("{ALTDOWN}{F4}{ALTUP}")
        Exitloop
    EndIf
WEnd

Share this post


Link to post
Share on other sites



Sorry Secure, I think I'm missing something on your post.

Share this post


Link to post
Share on other sites

One of the problems is that you're not checking the color more than once at the beginning. Try something like...

Do
    $var = PixelGetColor(622, 301)
    $var1 = Hex($var, 6)
    Sleep(100)
Until $var1 <> 'FFC700'

MouseClick("left", 520, 443, 1)

If you want to wait until it says "100% - Blizzard Updater" maybe that should be in the title or text? Try to make sure you're using the right wintitlematch mode, and your title/text is what it should be. Also, the text is optional.

Share this post


Link to post
Share on other sites

Thanks Xcal. The Do loop for the first part, I missed that one. :)

For the second loop, the 100% will only show up when it's done downloading. Is my loop setup right for that if I just change it to:

While 1
    If WinExists("100% - Blizzard Updater", "The update was successful.") Then
        Send("{ENTER}")
        Sleep(10000)
        Send("{ALTDOWN}{F4}{ALTUP}")
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Also, since Send acts on the active window and you're only checking if the window exists, it's not

exactly very safe. Consider replacing WinExists with WinActive and/or Send with ControlSend.

Btw, since nothing is done in your second loop before the window exists, you can just use WinWait

instead...

EDIT : Last note... to close the window you can just use Send("!{F4}") or even WinClose.

Edited by Helge

Share this post


Link to post
Share on other sites

Thanks Helge. Winwait worked great. Thanks.

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  
Followers 0