konani Posted May 1, 2010 Posted May 1, 2010 (edited) Hi all, I program a tool with 2 "Start" and "Stop" button (status of program depends on $status variable). When a program started, if condition is valid, it do something and sleep after 10 minutes. But when I press "Start", sometimes I cannot stop program by pressing "Stop" button. Maybe, because I use SLEEP() function, so I cannot press "Stop". Help me solve this problem. I wanna this program can stop at any time when the program has run. $delay = 600000 Func AutoRun() While 1 Select Case $status = "start" If <condition expression> Then ; do something, code here EndIf Sleep($delay) Case $status = "stop" ExitLoop EndSelect WEnd EndFunc Thanks in advance, Edited May 1, 2010 by konani
jchd Posted May 1, 2010 Posted May 1, 2010 Something like this? Func AutoRun() Local Const $delay = 600000 Local $timer = TimerInit() - $delay While 1 Select Case $status = "start" And TimerDiff($timer) >= $delay If <condition expression> Then ; do something, code here $timer = TimerInit() EndIf Sleep(50) Case $status = "stop" ExitLoop EndSelect WEnd EndFunc Exit This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
konani Posted May 1, 2010 Author Posted May 1, 2010 Something like this? Func AutoRun() Local Const $delay = 600000 Local $timer = TimerInit() - $delay While 1 Select Case $status = "start" And TimerDiff($timer) >= $delay If <condition expression> Then ; do something, code here $timer = TimerInit() EndIf Sleep(50) Case $status = "stop" ExitLoop EndSelect WEnd EndFunc Exit Thank you. But it don't work, because TimerDiff($timer) >= $delay is always false.
omikron48 Posted May 1, 2010 Posted May 1, 2010 (edited) When you say "program" is this some other program (like another script or executable) or are you referring to the script itself?You'd have to use a hotkey for what you want.EDIT: Also, why bother putting a boolean expression that will always be false?$status = "start" And TimerDiff($timer) >= $delayGiven this condition, it doesn't matter what value $status has if 'TimerDiff($timer) >= $delay' is always false. The end result will always be false. Edited May 1, 2010 by omikron48
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