Jump to content

What is wrong with this loop?


sevad
 Share

Recommended Posts

Hi, I'm relatively new to AutoIt and was writing some simple code to help me get the hang of it. When I started using simple loops I noticed that they weren't working. Can someone tell me what the problem is?

dim $value
$value = 1
run ("notepad.exe")
winwaitactive("Untitled - Notepad")

do 
If WinExists("Untitled -") Then
    send("how are you")
    sleep(200)
EndIf
while $value = 1

I know that this would be an infinite loop at this point if the loop were functioning correctly, but it only runs once, then shuts itself off. Any ideas anyone?

Edited by sevad
Link to comment
Share on other sites

its do until not , do while

Example

Global $value = 1
run ("notepad.exe")
WinWaitActive("Untitled - Notepad")

Do
If WinExists("Untitled - Notepad") Then
While WinActive("Untitled - Notepad")
    send("how are you")
    sleep(200)
WEnd
$value += 1 ; adds 1 to value which exits the loop
EndIf
Until $value <> 1
oÝ÷ ÚØb³¥ìb·^*.rZ,^^¥§pwhÁ«­¢+Ø)±½°ÀÌØíÙ±ÕôÄ)ÉÕ¸ ÅÕ½Ðí¹½ÑÁ¹áÅÕ½Ðì¤)]¥¹]¥ÑÑ¥Ù ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤()]¡¥±]¥¹á¥ÍÑÌ ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤)]¡¥±]¥¹Ñ¥Ù ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤(͹ ÅÕ½Ðí¡½ÜÉå½ÔÅÕ½Ðì¤(ͱÀ ÈÀÀ¤)]¹)]¹(
Edited by thatsgreat2345
Link to comment
Share on other sites

  • Moderators

its do until not , do while

Example

Global $value = 1
run ("notepad.exe")
WinWaitActive("Untitled - Notepad")

Do
If WinExists("Untitled - Notepad") Then
While WinActive("Untitled - Notepad")
    send("how are you")
    sleep(200)
$value += 1 ; adds 1 to value which exits the loop
EndIf
Until $value <> 1
oÝ÷ ÚØb³¥ìb·^*.rZ,^^¥§pwhÁ«­¢+Ø)±½°ÀÌØíÙ±ÕôÄ)ÉÕ¸ ÅÕ½Ðí¹½ÑÁ¹áÅÕ½Ðì¤)]¥¹]¥ÑÑ¥Ù ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤()]¡¥±]¥¹á¥ÍÑÌ ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤)]¡¥±]¥¹Ñ¥Ù ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤(͹ ÅÕ½Ðí¡½ÜÉå½ÔÅÕ½Ðì¤(ͱÀ ÈÀÀ¤)]¹)]¹(
Might want to check that first example you provided... think your missing something :whistle:

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.

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