XLimas Posted August 3, 2011 Share Posted August 3, 2011 Hello mates,Since I'm just a newbie, I'd like to ask you how to make infinite loop which doesn't use that much of CPU.I tried different loops in my small experience and all of them took my CPU to work at around 40-50%.Even function WinWait() uses my CPU same way.Here is shortened script i use:HotKeySet("{`}", "Startit") HotKeySet("{End}", "Finish") Do Sleep(100) Until False Func Startit() MouseClick("left") Send("^{c}") Send("!{TAB}") Send("^{v}") EndFunc Func Finish() Exit 0 EndFuncDo anyone know how i can get rid out of it?Is there any other way to make loops that doesn't use that much of CPU?Thanks in advance! Link to comment Share on other sites More sharing options...
Nonyamuff Posted August 3, 2011 Share Posted August 3, 2011 XLimas, I had the same issue in a script I built a while back. I think your sleep may be too short. I put in a sleep of 1 second (1000), and my CPU usage went from 50% to 0 - 1%. You may give that a shot. Link to comment Share on other sites More sharing options...
monoscout999 Posted August 3, 2011 Share Posted August 3, 2011 (edited) ?? that is strange, for me this script...HotKeySet("{`}", "Startit") HotKeySet("{End}", "Finish") Do Sleep(1) Until False Func Startit() MouseClick("left") Send("^c") Send("!{TAB}") Send("^v") EndFunc Func Finish() Exit EndFuncgives me this CPU usage.If i dont put any sleep the CPU usage is about 40% or 50%Are you shure that process is the one from that script, maybe is a remaining script test.EDITED: Also i correct something from your script. v and c are not special characters so dont have any {} Edited August 3, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
XLimas Posted August 3, 2011 Author Share Posted August 3, 2011 Hmmm, maybe i wrote a bad example... Try this one: HotKeySet("{`}", "Startit") HotKeySet("{End}", "Finish") $var=0 Do If $var=1 Then ;Repeats some tasks Send("a") EndIf Until False Func Startit() If $var=0 Then $var=1 Else $var=0 EndIf EndFunc Func Finish() Exit 0 EndFunc Maybe i use wrong syntax or i do something wrong? Link to comment Share on other sites More sharing options...
monoscout999 Posted August 3, 2011 Share Posted August 3, 2011 (edited) Hmmm, maybe i wrote a bad example... Try this one: HotKeySet("{`}", "Startit") HotKeySet("{End}", "Finish") $var=0 Do If $var=1 Then ;Repeats some tasks Send("a") EndIf Until False Func Startit() If $var=0 Then $var=1 Else $var=0 EndIf EndFunc Func Finish() Exit 0 EndFunc Maybe i use wrong syntax or i do something wrong? You need to put a sleep in the loop. with that script you get for shure an CPU usage above 40% Edited August 3, 2011 by monoscout999 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