Sign in to follow this  
Followers 0
AutoChris

Processor usage

5 posts in this topic

I could have sworn I had seen this question asked sometime before, but after doing some indepth searching on the site, I cannot seem to find it.

So do any of you know how I can check to see if the processor usage is below a certain percentage? Or even if a specific application is using a certain percentage of the processor?

I have a script I am running, but this poorly written program (don't get me started on some of the lame programs my company uses!) I am manipulating hits close to 100% processor usage any time I change something in it. Then I have to wait until it gets back to a somewhat normal processor load and run some more commands. (Each time it takes between 10 and 30 seconds to get back to normal) I have been using Sleep () but this is obviously not ideal since I would like to get the script finished with its business as soon as possible.

Thank you for your input.

Share this post


Link to post
Share on other sites



I could have sworn I had seen this question asked sometime before, but after doing some indepth searching on the site, I cannot seem to find it.

So do any of you know how I can check to see if the processor usage is below a certain percentage? Or even if a specific application is using a certain percentage of the processor?

I have a script I am running, but this poorly written program (don't get me started on some of the lame programs my company uses!) I am manipulating hits close to 100% processor usage any time I change something in it. Then I have to wait until it gets back to a somewhat normal processor load and run some more commands. (Each time it takes between 10 and 30 seconds to get back to normal) I have been using Sleep () but this is obviously not ideal since I would like to get the script finished with its business as soon as possible.

Thank you for your input.

<{POST_SNAPBACK}>

seems like kind of a catch 22...the more often you check the processor stats, the greater the strain, and the greater the chance that your script may cause the exact condition it's looking for...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

seems like kind of a catch 22...the more often you check the processor stats, the greater the strain, and the greater the chance that your script may cause the exact condition it's looking for...

<{POST_SNAPBACK}>

I had thought the same thing, but I would only have to check the processor load every couple seconds at the most so there should be very little usage. Plus, the processor load is in the vicinity of 1% to 2% so checking to see if it is below 30%, for example would take into account the processor usage of the script itself, which I doubt will use much of the processor anyway.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Didn't someone post a function called _Busy in the scripts and scraps section that might achieve this?

Ah here it is

Func _Busy($szTitle, $szText="")
  ;==============================================
  ; Local Constant/Variable Declaration Section
  ;==============================================
   Local $CPU
   Local $State
   If ProcessExists ("taskmgr.exe") = 0 Then 
       Run ("taskmgr.exe","",@SW_HIDE)
   EndIf
   Do
      Do
         TrayTip("", "Waiting for " & $szTitle, 1)
         Sleep(100)
         $CPU = StatusbarGetText("Windows Task Manager", "", 2)
         $CPU = StringTrimRight($CPU, 1);Remove the %
         $CPU = StringRight($CPU, 3);Get the possible 3 digits
         $CPU = Int(StringReplace($CPU, ":", ""));Remove the colon and convert to an integer
         TrayTip("Clear", "", 0)
      Until $CPU < 15
      
      Do
         TrayTip("", "Waiting for " & $szTitle, 1)
         Sleep(100)
         TrayTip("Clear", "", 0)
      Until MouseGetCursor() <> 15
      
      WinActivate($szTitle, $szText)
      TrayTip("", "Waiting for " & $szTitle, 1)
      $State = WinGetState($szTitle, $szText)
      TrayTip("Clear", "", 0)
   Until (BitAND($State, 15) = 15 Or BitAND($State, 13) = 13 Or BitAND($State, 47) = 47)
EndFunc  ;==>_Busy

Just change the value of $CPU to what you want?

Edited by Lee Evans

Share this post


Link to post
Share on other sites

Didn't someone post a function called _Busy in the scripts and scraps section that might achieve this?

<{POST_SNAPBACK}>

Interesting script. Apparently, you have to have the Task Manager window open and then it reads the processor load from the status bar. Simple, but I suppose it will work. I was hoping for something a little more ... advanced, but I think it should work for my purposes. Thanks for pointing it out.

Also thanks to esfalk for writing the function, JdeB for coming up with the idea in the first place and scriptkitty for expanding on the idea. I'd also like to thank my mother for all of the support... Oh, sorry. I got carried away.

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