Bower Posted November 11, 2008 Posted November 11, 2008 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?
Richard Robertson Posted November 11, 2008 Posted November 11, 2008 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.
FreeFry Posted November 11, 2008 Posted November 11, 2008 As Richard said, have a look at the While - WEnd loop in the helpfile, should get you started. 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
Valuater Posted November 11, 2008 Posted November 11, 2008 (edited) 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 November 11, 2008 by Valuater
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now