Sign in to follow this  
Followers 0
monte

script consuming cpu cycels

11 posts in this topic

Hello, my script is consuming all my cpu cycles and slowing down my computer. It makes sure my thunderbird email client is running and in the system tray if someone tries to close it. Any ideas?

#notrayicon

while 1
  If not ProcessExists("thunderbird.exe") Then
    Run("C:\Program Files\Mozilla Thunderbird\thunderbird.exe")
    WinWait("Inbox for")
    winactivate("Inbox for")
    Send("^+m")
  endif
wend

Share this post


Link to post
Share on other sites



Hello, my script is consuming all my cpu cycles and slowing down my computer. It makes sure my thunderbird email client is running and in the system tray if someone tries to close it. Any ideas?

#notrayicon

while 1

  If not ProcessExists("thunderbird.exe") Then
    Run("C:\Program Files\Mozilla Thunderbird\thunderbird.exe")
    WinWait("Inbox for")
    winactivate("Inbox for")
    Send("^+m")
  endif
wend
well first off, I really don't like using the "not" thing, so I made it this way. but also maybe a sleep timer.

#notrayicon

while 1
  sleep(1000)
  If ProcessExists("thunderbird.exe") Then
     Exit
  Else
    Run("C:\Program Files\Mozilla Thunderbird\thunderbird.exe")
    WinWait("Inbox for")
    winactivate("Inbox for")
    Send("^+m")
  EndIf
WEnd

Share this post


Link to post
Share on other sites

well first off, I really don't like using the "not" thing, so I made it this way. but also maybe a sleep timer.

The NOT thing as you call it is fine to use and a sleep(10) is probably enough to give other processes some time as well...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

The NOT thing as you call it is fine to use and a sleep(10) is probably enough to give other processes some time as well...

You could probably add a sleep(250) to the loop without it seriously impacting script performance, and that should take your processor usage down to single figures. Or, while Thuunderbird isn't running you could introduce a longer delay betweem checks, and make it say 25ms while it is running.

Share this post


Link to post
Share on other sites

The NOT thing as you call it is fine to use and a sleep(10) is probably enough to give other processes some time as well...

yeah its fine I just don't like it.

Usually a While loop needs a sleep, if not it just keeps doing the function so fast, its kind of silly.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yeah its fine I just don't like it.

Its fine when you don't like it but you made it sound like its something to avoid which I don't agee with.

Usually a While loop needs a sleep, if not it just keeps doing the function so fast, its kind of silly.

I specified the Sleep(10) since that is the default also used by the GUIGetMsg() for example, which is used in a loop a lot.

:)

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Its fine when you don't like it but you made it sound like its something to avoid which I don't agee with.

I specified the Sleep(10) since that is the default also used by the GUIGetMsg() for example, which is used in a loop a lot.

:)

i would avoid it personally.

i would in all cases prefer a nice

If
and
Else
and
EndIf

Share this post


Link to post
Share on other sites

i would avoid it personally.

i would in all cases prefer a nice

If
and
Else
and
EndIf
That sounds nice ;) . But you changed the conditions to make things look nice :D . You added "Exit" into the condition when the user did not have it to begin with so perhaps you should learn to use "Not" to be look nice to suit the conditions needed :) ?

Share this post


Link to post
Share on other sites

That sounds nice :D . But you changed the conditions to make things look nice :( . You added "Exit" into the condition when the user did not have it to begin with so perhaps you should learn to use "Not" to be look nice to suit the conditions needed :) ?

the exit was just my addition, easy enough toedit it out and instead say
sleep(0)

would he really want it constantly running>?

i imagined he would want it to run once and done.

everytime you close it there it is again ;) who wants that?>

if he does then he can take it out

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

the exit was just my addition, easy enough toedit it out and instead say

sleep(0)

would he really want it constantly running>?

i imagined he would want it to run once and done.

everytime you close it there it is again ;) who wants that?>

if he does then he can take it out

So you think that looks better then using Not? Please stop doing this to yourself. :) Edited by MHz

Share this post


Link to post
Share on other sites

So you think that looks better then using Not? Please stop doing this to yourself. :)

ofc

Share this post


Link to post
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
Sign in to follow this  
Followers 0