Sign in to follow this  
Followers 0
leuce

Misbehaving Do...Until loop

7 posts in this topic

G'day everyone

I'm using Do...Until in a loop and I want the script to exit that loop when the time is ripe. However, the loop doesn't want to stop looping. Here's my code (the entire script is attached -- the additional programs in it are ResHack and XnView):

$a = 0

Do

;Some stuff here

If WinExists ("Dialog", "") Then
; Do some XYZ stuff
Else
$a = 1
EndIf

Until $a = 1

My reasoning is that once $a is 1, the Do loop should stop... right? But it doesn't. It continues even though the window "Dialog" no longer exists. Any ideas?

Thanks

Samuel

screencapscript2.zip

Share this post


Link to post
Share on other sites



You could always do it with a while/wend loop a bit different:

While 1
    If WinExists ("Dialog", "") Then
        WinActivate ("Dialog", "")
        WinWaitActive ("Dialog", "")
        Send ("!d")
        Sleep (100)
        $a = 1
    EndIf
    If Not WinExists('Dialog') And $a = 1 Then ExitLoop
WEnd


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

While WinExists("Dialog", "")
;stuff to do while the dialog exists;
WEnd

?

Edit: ChrisL beat me to it :whistle:

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

He had alot more stuff in that loop is why I suggested what I did.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

He had alot more stuff in that loop is why I suggested what I did.

he's righht of course. :whistle:

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

G'day everyone

I'm using Do...Until in a loop and I want the script to exit that loop when the time is ripe. However, the loop doesn't want to stop looping. Here's my code (the entire script is attached -- the additional programs in it are ResHack and XnView):

$a = 0

Do

;Some stuff here

If WinExists ("Dialog", "") Then
; Do some XYZ stuff
Else
$a = 1
EndIf

Until $a = 1

My reasoning is that once $a is 1, the Do loop should stop... right? But it doesn't. It continues even though the window "Dialog" no longer exists. Any ideas?

Thanks

Samuel

I think SmOke_N was closest, but the logic is changed my moving the $a=1. I would have dropped it completely and put:

While 1
    
    ; Other stuff from the original Do loop...

    If WinExists("Dialog", "") Then
        WinActivate("Dialog", "")
        WinWaitActive("Dialog", "")
        Send ("!d")
        Sleep (100)
    Else
        ExitLoop
    EndIf
WEnd

Allows you to check that the script gets to that code at all.

:whistle:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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