Jump to content

Loops eating my CPU


Recommended Posts

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%.

Posted Image

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
EndFunc

Do 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

?? 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
EndFunc

gives me this CPU usage.

Posted Image

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 by monoscout999
Link to comment
Share on other sites

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

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 by monoscout999
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...