Sign in to follow this  
Followers 0

Exit loop and continue loop

10 posts in this topic

Posted

I have a While loop that does some stuff and I want to add in an If condition to short circuit the loop if certain conditions are met.

Problem is, when I use Exitloop it completely stops the script. How do I make it so that when the If condition is true then the script clicks the next button(bolded below), breaks the loop, then restarts it again from the next iteration.

While $j > 0
WinActivate("Home Page - Mozilla Firefox")
$hWnd = WinGetHandle("Home Page - Mozilla Firefox")
_ClipBoard_SetData ("0")
Send("{END}")
Sleep(100)
MouseClick("right", 554, 606, 1, 0)
Send("E")
Sleep(10)
Send("{ENTER}")
Sleep(10)
Send("{ESC}")
$sMail = ClipGet()
_ClipBoard_SetData ("0")
MouseClick("right", 554, 730, 1, 0)
Send("E")
Sleep(10)
Send("{ENTER}")
Sleep(10)
Send("{ESC}")
$sMail2 = ClipGet()
If $sMail AND $sMail = 0 Then ExitLoop

MouseClick("left", 551, 584, 3, 0)
Send("^c")
$nametrim = ClipGet()
$oExcel = _ExcelBookAttach("Book1.xls", "FileName")
_ExcelWriteCell($oExcel, $nametrim, $i, 1)
_ExcelWriteCell($oExcel, $sMail, $i, 2)
WinActivate("Home Page - Mozilla Firefox")
[b]MouseClick("left", 779,  931, 1, 0)[/b]
Sleep(1900)

$i = $i + 1

$j = $j - 1
WEnd

Share this post


Link to post
Share on other sites



Posted

ContinueLoop vice ExitLoop.

;)

Share this post


Link to post
Share on other sites

Posted

What do you mean by vice?

Where would I put ContinueLoop?

Share this post


Link to post
Share on other sites

Posted

Ok if I use ContinueLoop then I get stuck in an infinite loop.

Is there a way to have the If condition do 2 things?

If $sMail = 0 Then MouseClick("left", 779, 931, 1, 0) AND ContinueLoop

I want to do something like that but that gives me an error.

Share this post


Link to post
Share on other sites

Posted

Did you even bother reading the help file? Coding syntax is in there, you know...

If $sMail = 0 Then
    MouseClick("left", 779, 931, 1, 0)
    ContinueLoop
EndIf

Share this post


Link to post
Share on other sites

Posted

You might want to take another look at this part of your code also

If $sMail AND $sMail = 0 Then

Share this post


Link to post
Share on other sites

Posted

Did you even bother reading the help file? Coding syntax is in there, you know...

If $sMail = 0 Then
    MouseClick("left", 779, 931, 1, 0)
    ContinueLoop
EndIf

Yes I did. That's how I discovered ContinueLoop and ExitLoop. I looked at the example and it did not show me or tell me about the syntax.

Thanks for the help though.

Share this post


Link to post
Share on other sites

Posted (edited)

Hmm. Apparently the immediately viewable examples (even in the ones in the Keyword/Statement Reference) all contain single statement samples.

Guess you don't code much or aren't that exposed to code since it's pretty common knowledge to coders that you can stick however many statements you want inside conditional statements or loops.

Edited by omikron48

Share this post


Link to post
Share on other sites

Posted

@homemade: Did you get it figured out? Couldn't really tell if you arrived at a working solution.

;)

Share this post


Link to post
Share on other sites

Posted

Yeah, I came up with a solution thanks to omikron48's example.

I am still a newbie and sometimes the example scripts in the help file don't help with more complicated stuff.

Thanks for the help everybody!

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