Jump to content

DO..While loop = 99% CPU useage


Recommended Posts

Hi everyone, first post!

First off, I dont have any coding experience. I have just kinda been searching the help file until i find what im looking for. It has worked pretty good up until now.

Heres what im trying to do:

I have a windows 7 Media Center dedicated machine in my living room. I need to switch the resolution to 720x480 when the process HuluDesktop.exe is running (slow machine :D), and switch back to 1280x720 when it is not. Here is what I have written:

It was meant to run at startup and remain a background process at all times.

; $Res is 720 if 720p and 480 if 480p
$Res=Int(720)
Sleep(60000); wait for windows media center to start
Do
    if ProcessExists( "HuluDesktop.exe") And $Res=720  then ;if hulu is running and screen resolution is 720p then
        send("^!4")     ;change resolution to 480p via hotkey
        $Res=Int(480)   ;and make $Res reflect 480p
    EndIf
    If ProcessExists("HuluDesktop.exe")=0 and $Res=480 Then ;if hulu isnt running and screen resolution is 480p then
        send("^!7")     ;change resolution to 720p via hotkey
        $Res=Int(720)   ;and  make $Res reflect 720p
    EndIf
Until ProcessExists("ehshell.exe")   ;windows media center process

So, it works great. But Hulu Desktop stutters nonstop because this script is eating up all of my CPU (99%). If i put a sleep command in the loop it is better, but it still stutters everytime the loop runs again and the CPU useage jumps up to 100%.

Do you guys know of a better way to do this?

Edited by AaronBaird
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...