Jump to content

Do...Until Loop weirdness


Recommended Posts

I have this loop in my code right now...

$imageColor = PixelGetColor(376,533)
            $imageColorHex = Hex($imageColor)
                Do
                    $imageColor = PixelGetColor(376,533)
                    $imageColorHex = Hex($imageColor)
                    ;MsgBox(0,'','In Loop Hex: ' & $ImageColorHex)
                Until $imageColorHex == '00FFFFFF' 
                MsgBox(0,'','Out of Loop', 5)
            MouseClick('Left',376,533)
            ;New window

The MsgBox inside the Do...Until loop, if it is commented out...my script pauses, and I don't get the "Out of Loop" message box. However, If I uncomment the msgbox in the Do loop, I get the msgbox in the loop, and the msgbox when it leaves the loop, and my mouseclick....??

Link to comment
Share on other sites

I tested this snippet and it works ok for me. It will show the out of loop message box as soon as there is a white pixel at that spot and then moves the mouse to it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I use sometimes console output for debugging and sometimes messagebox, but my choice of debugging small snippets is Beep()

Try your code with Beep() :)

Do
        $imageColor = PixelGetColor(376,533)
        $imageColorHex = Hex($imageColor)
        Beep(800,100)
Until $imageColorHex == '00FFFFFF' 
Beep(600,100)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Beep? lol, never used it...maybe I will give it a whirl

Edit: not much information gained from beep, most the time I debug to get some sort of variable being passed, so it wouldn't help, but I do see it's uses.

Edited by dufran3
Link to comment
Share on other sites

I Use Beep() at diferent frequencies for different expected situations, so I know whats going on with it even if I'm in my kitchen making a nice cup of tea :)

That's another great Idea of debugging. Great! I love it. I do have to try this in the next days.

What do you think of running that in a big office? :)

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
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...