Jump to content

script consuming cpu cycels


monte
 Share

Recommended Posts

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

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
Link to comment
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 :) ?
Link to comment
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

Link to comment
Share on other sites

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