Guest Spike Posted April 5, 2004 Share Posted April 5, 2004 Greetings from Downunder, I've just written this poor man's cookie cruncher for Opera 7.23 It works ok but uses 100% cpu cycles. Any suggestion for recoding to reduce cpu cycles ?????? TIA Spike here is the code Global $Paused HotKeySet("{F10}", "Terminate"); example F10 to exit $title=0 while $title=0 $title=winactive("The server wishes to send you a cookie") if $title=1 then ;MsgBox(0, "Value =","cookie time") ;sleep(1000) winkill("The server wishes to send you a cookie") $title=0 endif wend Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
Gene Posted April 5, 2004 Share Posted April 5, 2004 Greetings from Downunder,I've just written this poor man's cookie cruncher for Opera 7.23It works ok but uses 100% cpu cycles.Any suggestion for recoding to reduce cpu cycles ??????TIASpikehere is the codeGlobal $PausedHotKeySet("{F10}", "Terminate"); example F10 to exit $title=0while $title=0$title=winactive("The server wishes to send you a cookie")if $title=1 then ;MsgBox(0, "Value =","cookie time");sleep(1000)winkill("The server wishes to send you a cookie")$title=0endifwendFunc Terminate() Exit 0EndFuncPut Sleep(100) in at the beginning or the ending of your loop. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Guest Spike Posted April 5, 2004 Share Posted April 5, 2004 Thanks Gene, That fixed it, but why ?? Any explanations ??? Tia Spike Link to comment Share on other sites More sharing options...
Valik Posted April 5, 2004 Share Posted April 5, 2004 AutoIt runs balls out. Even though it was doing nothing, it was doing it very very fast and thus, using up cycles. By telling it to Sleep for 100 ms, you are literally telling it to slow down and pause for 100 ms between times the loop executes. Link to comment Share on other sites More sharing options...
Guest Spike Posted April 5, 2004 Share Posted April 5, 2004 Thanks Valik, I sort of came to that answer myself after i sat down and thought about it for a while! Thanks for the help everybody. Spike Link to comment Share on other sites More sharing options...
scriptkitty Posted April 5, 2004 Share Posted April 5, 2004 You can dramatically reduce autoit from 100%CPU to say 2% CPU by adding Sleep(1) or sleep(10) Your popups would be virtually killed before they start without a huge CPU use. AutoIt3, the MACGYVER Pocket Knife for computers. 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