Solomon Posted March 13, 2006 Posted March 13, 2006 I have some code that I need to have run every 5 seconds, to check to see if a file and process exist, and exit if they dont. If ProcessExists("Backup.exe") Then FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz") EndIf If Not ProcessExists("Backup.exe") Then Exit Sleep(5000) Is it possible to use something other than a combination of Sleep(5000) and repeating the above code millions of times? I mean, its working, and working fine, so perhaps I should just live with it, but I was thinking that the code would look nicer if it did [something] until [something else].
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 AdlibEnable('_CheckForProcess', 5000); will check process every 5 seconds or so While 1 Sleep(1000) WEnd Func _CheckForProcess() If ProcessExists("Backup.exe") Then FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz") Else Exit Exit EndFunc 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.
Valuater Posted March 13, 2006 Posted March 13, 2006 maybe expandcollapse popup; 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 If $Paused Then AdlibEnable("myadlib", 5000) While $Paused Sleep(100) ToolTip('Script is "Running"', 0, 0) WEnd ToolTip("") AdlibDisable ( ) EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMessage() MsgBox(4096, "", "This is a message.") EndFunc ;==>ShowMessage Func myadlib() If ProcessExists("Backup.exe") Then FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz") EndIf EndFunc ;==>myadlib ********** not tested 8)
MHz Posted March 13, 2006 Posted March 13, 2006 While ProcessExists('Backup.exe') FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz") Sleep(5000) WEnd
Valuater Posted March 13, 2006 Posted March 13, 2006 While ProcessExists('Backup.exe') FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz") Sleep(5000) WEnd sometimes.... "Less is Better" 8)
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 sometimes.... "Less is Better"8)I keep trying to tell my wife that 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.
Solomon Posted March 13, 2006 Author Posted March 13, 2006 Blimey, that was quick! Thanks very much, guys!
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 Blimey, that was quick! Thanks very much, guys!Yeah... some of these guys have nothing better to do other than sit around and help (or we have better things to do... but our priorities are screwed)... so you gotta check frequently . 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.
Bert Posted March 13, 2006 Posted March 13, 2006 @Smoke: I tried that too, it didn't go over well at all. The Vollatran project My blog: http://www.vollysinterestingshit.com/
MHz Posted March 13, 2006 Posted March 13, 2006 I keep trying to tell my wife that While you are using it in a loop, your wife will be happy.
seandisanti Posted March 13, 2006 Posted March 13, 2006 While you are using it in a loop, your wife will be happy. unless every iteration is executing on the girlfriend.... speaking of... what an awesome weekend.
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 unless every iteration is executing on the girlfriend.... speaking of... what an awesome weekend.Ha!!... I'll have to remember to ask about it... (The weekend that is) ... I don't have a girlfriend to tell her about... but I love hearing about hers!! 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.
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