Jump to content

Recommended Posts

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

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.

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...