ZoltanE Posted February 14, 2010 Posted February 14, 2010 Are there best practices to keep AutoIt scriptseasy on the CPU?I'm on a Q6600@2.4Ghz with Win7 and my floating toolbarscript costs a constant 5-8%.With a sleep(100) in the main loop it gets downto 1-2%, but I read somewhere that a sleep is notrecommended there.
Richard Robertson Posted February 14, 2010 Posted February 14, 2010 Sleep is only not recommended when you are already using GUIGetMsg. If you aren't using that in the same loop, go ahead and add a sleep.
ZoltanE Posted February 15, 2010 Author Posted February 15, 2010 Well, I am using GUIGetMsg(). So sleep makes the gui laggy... Hmm, I guess I'll have to experiment with sleep times and see which value starts to cause problems.
whim Posted February 15, 2010 Posted February 15, 2010 (edited) Zoltan, try replacing: Toolbar_State() ; Toggle "AlwaysOnTop" setting as required. Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI. with Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI. ; avoid unnecessary processing when no events ... If $iMsg = 0 Then ContinueLoop Toolbar_State() ; Toggle "AlwaysOnTop" setting as required. Of course this will only help if it actually is Toolbar_State() that eats your CPU edit: not tested, don't have PS HTH, whim Edited February 15, 2010 by whim
MvGulik Posted February 15, 2010 Posted February 15, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
NerdFencer Posted February 15, 2010 Posted February 15, 2010 When using sleep, have a delay of 15. This provides no noticeable lag, and drastically reduces CPU usage. This is the lowest time that Sleep can accurately delay for on all windows platforms. _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell
picea892 Posted February 15, 2010 Posted February 15, 2010 Use onevent mode if you are truly serious about reducing CPU usage.
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