fi3l2 Posted March 18, 2005 Posted March 18, 2005 hey all, i am a definate noob to scripting here. I found this after I was messing with an Andy bot for diablo II and wanted to try my own tweaks. Below is my attempt to run any file (another .au3 script, or anything else) at a certain time that is specifed. the reason I did it this way is because from what I was seeing, the Run() command doesn't work with other scripts.... which is why I got into autoit in the first place basically to do things when I am not here :-D lemme know what you guys thing and post some major improvements to it if you wish (plz!) Thanks :-D ;Runs Anything at a certain time #include <Date.au3> $program = FileOpenDialog("Choose file...","My Computer","All") $time = InputBox("Time", "What time would you like it to run?" & @CRLF & "hh:mm:ss AM/PM", _NowTime(), "") $count = 0 while $time > 0 if $time = _NowTime() Then Send("#r") WinWaitActive("Run") Send($program & "{Enter}") $count = $count + 1 Sleep(1000) EndIf Wend One problem I have seen, the script does not end after the program runs, the autoit is still in a tray icon for the script, anyone shed some light as to what is keeping this script alive after the while loop is done?
buzz44 Posted March 18, 2005 Posted March 18, 2005 (edited) nice first script =), to make it end simply add an "exit" in the if statement while $time > 0 if $time = _NowTime() Then Send("#r") WinWaitActive("Run") Send($program & "{Enter}") $count = $count + 1 Sleep(1000) Exitloop EndIf Wend btw $program = FileOpenDialog("Choose file...","My Computer","All") didnt work for me, i changed it to $program = FileOpenDialog("Choose file...","My Computer","All(*.*)") Edited March 18, 2005 by burrup qq
steveR Posted March 18, 2005 Posted March 18, 2005 (edited) Plus put the Sleep() statement outside the if\endif condition, it will make your CPU happier while $time > 0 if $time = _NowTime() Then Send("#r") WinWaitActive("Run") Send($program & "{Enter}") $count = $count + 1 Exitloop EndIf Sleep(1000) Wend Edited March 18, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
fi3l2 Posted March 18, 2005 Author Posted March 18, 2005 ty ty runs great now awesome thanks again gotta get back to learning even more off the forums latez
Ejoc Posted March 18, 2005 Posted March 18, 2005 What about having it sleep the time difference of now and when it needs to go off. ie: 1) Get the time you want it to go off 2) sleep(1000*(difference in seconds between then and now)) 3) execute your code this will save you some cpu Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
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