Sign in to follow this  
Followers 0
sevad

What is wrong with this loop?

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Do / Until

While / WEnd

For / Next


[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thank you so much smoke_n and thatsgreat! Sorry about the stupid mistake.

Share this post


Link to post
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)
$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:

[center]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.[/center]

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