Jump to content

Exit loop and continue loop


Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
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...