Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Exit loop and continue loop


  • Please log in to reply
9 replies to this topic

#1 homemade

homemade

    Seeker

  • Active Members
  • 27 posts

Posted 05 January 2010 - 10:29 PM

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.

Plain Text         
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








#2 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 05 January 2010 - 10:33 PM

ContinueLoop vice ExitLoop.

;)
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

#3 homemade

homemade

    Seeker

  • Active Members
  • 27 posts

Posted 05 January 2010 - 10:40 PM

What do you mean by vice?
Where would I put ContinueLoop?

#4 homemade

homemade

    Seeker

  • Active Members
  • 27 posts

Posted 05 January 2010 - 10:55 PM

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.

#5 omikron48

omikron48

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 796 posts

Posted 05 January 2010 - 11:04 PM

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


#6 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 11,236 posts

Posted 05 January 2010 - 11:46 PM

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

If $sMail AND $sMail = 0 Then

#7 homemade

homemade

    Seeker

  • Active Members
  • 27 posts

Posted 06 January 2010 - 05:11 PM

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.

#8 omikron48

omikron48

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 796 posts

Posted 07 January 2010 - 12:25 AM

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, 07 January 2010 - 12:25 AM.


#9 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 07 January 2010 - 06:36 PM

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

;)
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

#10 homemade

homemade

    Seeker

  • Active Members
  • 27 posts

Posted 08 January 2010 - 05:09 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users