Jump to content

Another Question , about avoiding endless loops


Recommended Posts

here is some of my code thus far.

BlockInput(1)

Dim $i

Dim $text

;Declaring the name of the service you are searching for

Const $service= "Server"

Send("#r")

WinWaitActive("Run", "", 1)

send("c:\windows\system32\services.msc")

sleep(50)

send("{enter}")

WinWaitActive("services","",1)

send("{TAB}")

Do

send("{ENTER}")

sleep(200)

send("^C")

$text=ClipGet()

If $text <> $service Then

send("{ESC}")

Endif

send("{DOWN}")

until $text==$service

send("+{TAB}")

sleep(50)

Send("{right}")

sleep(50)

Send("{tab}")

sleep(50)

Send("{DOWN}")

sleep(50)

BlockInput(0)

Say for intsance that for some odd reason or another, the "Server" Service was not running and the script just kept running through all the services. Should I encapsulate the Do...Until loop in like a for next loop that just ran twice and upon failure ended the script? BTW is there an end script function ? I know lots of dumb questions today, I am still learning :D

Link to comment
Share on other sites

  • Moderators

End Script Function = Exit

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

i just kind of skimmed it but i didnt see whuile so idont know how you do loops... but instead of while 1 you could use

Dim $C

$C = 0

While $C < 2

blah blah blah

$C = $C + 1

WEnd

or I think there is a timeout thing so it could wait an amount of time.

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