arminius Posted April 16, 2008 Share Posted April 16, 2008 ok, I've created a script that is designed to run in the background and because I'm a forgetful person it pops up reminders at certain times here is an example of the scrip, I have cut most of it's content and altered the real expiry date of my credit card CODEDo ; Credit Card If @YEAR=2012 And @MON=05 And @MDAY=05 And @HOUR=00 And @MIN=00 And @Sec=00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Month on 06-05-2012") If @YEAR=2012 And @MON=05 And @MDAY=27 And @HOUR=00 And @MIN=00 And @Sec=00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Week on 06-05-2012") If @YEAR=2012 And @MON=05 And @MDAY=29 And @HOUR=00 And @MIN=00 And @Sec=00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Day on 06-05-2012") Until Not ProcessExists("System") now when run in this form it chews up processor power to 100 percent, but when I introduced a Sleep(1) it dropped to almost nothing, I was under the impression it executes every microsecond by default anyway? does anyone know what it's doing when their is no sleep, why it's chewing up so much processor, and is my solution the best one? does anyone know a better way to minimise processor use, since I plan to have this script running indefinitly. oh is my not processexists("system") the best way to keep it going forever as well? Link to comment Share on other sites More sharing options...
Tomb Posted April 16, 2008 Share Posted April 16, 2008 what its doing with no sleep is: it is running over and over so fast with no breaks. running many times every second, burning up all of your CPU usage. Link to comment Share on other sites More sharing options...
NELyon Posted April 16, 2008 Share Posted April 16, 2008 For the second question, you are using a Do loop in a totally unnecessary way. Use a While loop instead. While 1 If @YEAR = 2012 And @MON = 05 And @MDAY = 05 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Month on 06-05-2012") If @YEAR = 2012 And @MON = 05 And @MDAY = 27 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Week on 06-05-2012") If @YEAR = 2012 And @MON = 05 And @MDAY = 29 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Day on 06-05-2012") WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 16, 2008 Share Posted April 16, 2008 For the second question, you are using a Do loop in a totally unnecessary way. Use a While loop instead. While 1 If @YEAR = 2012 And @MON = 05 And @MDAY = 05 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Month on 06-05-2012") If @YEAR = 2012 And @MON = 05 And @MDAY = 27 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Week on 06-05-2012") If @YEAR = 2012 And @MON = 05 And @MDAY = 29 And @HOUR = 00 And @MIN = 00 And @SEC = 00 Then MsgBox(4096, "Reminder", "Your Credit Card Expires in 1 Day on 06-05-2012") WEnd Did you try that? It will peg the CPU also, and for the same reason. The loop needs a Sleep() in it wheter it's a Do/Until or While/WEnd. Something that needs to update that rarely should probably be a scheduled task, though. It doesn't need to be running all the time. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted April 16, 2008 Share Posted April 16, 2008 Did you try that? It will peg the CPU also, and for the same reason. The loop needs a Sleep() in it wheter it's a Do/Until or While/WEnd. Something that needs to update that rarely should probably be a scheduled task, though. It doesn't need to be running all the time. Or a timer(s) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Swift Posted April 16, 2008 Share Posted April 16, 2008 What Tomb Said, When there is no sleep it will run NON-STOP! Over and over...over...and over...but with a 1 millisecond sleep, it will slow it down. Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 16, 2008 Share Posted April 16, 2008 Or a timer(s)Even if you use TimerInit()/TimerDiff() for the timing, or use AdLibEnable(), there still has to be a loop to keep the script running, and that will still require a Sleep() to not spike the CPU.PHhbbbbbbbbbbbbbbst! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted April 16, 2008 Share Posted April 16, 2008 Even if you use TimerInit()/TimerDiff() for the timing, or use AdLibEnable(), there still has to be a loop to keep the script running, and that will still require a Sleep() to not spike the CPU.PHhbbbbbbbbbbbbbbst! I said timer(s) not TimerInit/TimerDiff. "_Timer_xxxx"PHhbbbbbbbbbbbbbbst! SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted April 16, 2008 Share Posted April 16, 2008 Did you try that? It will peg the CPU also, and for the same reason. The loop needs a Sleep() in it wheter it's a Do/Until or While/WEnd. Something that needs to update that rarely should probably be a scheduled task, though. It doesn't need to be running all the time. I was solely answering his second question as Tomb had already answered his first. I just directly transfered his code from a Do loop to a While loop to show him how. Link to comment Share on other sites More sharing options...
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