Jump to content
Sign in to follow this  
Bower

Loop need help!

Recommended Posts

Bower

Hello, I am a little, okay a lot confused on how to loop a script, meaning to make it never stop until the program is closed?

Share this post


Link to post
Share on other sites
Richard Robertson

There are a lot of ways you can do that. The most common is a

While 1

WEnd

You can insert looping code inside of it or just put a sleep and use event driven code. All you need to do is add an Exit somewhere to close the script.

Share this post


Link to post
Share on other sites
FreeFry

As Richard said, have a look at the While - WEnd loop in the helpfile, should get you started. :mellow:

A simple example would be:

While 1
; code here will loop continously.
    Sleep(25); add a sleep so it will not strain your cpu to much.
WEnd

Share this post


Link to post
Share on other sites
Valuater

This is very useful for "Bots"

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

8)

Edited by Valuater

NEWHeader1.png

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  

×