ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

use AHK to determine CPU usgae of any given process?

<< < (3/4) > >>

Shades:
You can also take a look at 'Prism HUD'

This tool only shows progress bars (in opaque) how much CPU a process uses as well as the total load. When there is no load the bar disappears. It does the same with Network load and disk usage. Free and portable.

AEN007:
8November2011

Greetings.

I have a maybe a dozen WTM-related AHK scripts.

Here is a modified/enhanced version of what I already posted»

--- Code: Autohotkey ---scrX := 1    Perc := "%"    StatusBarGetText, CPU, 2, Windows Task ahk_class #32770    SLEEP, %Slb%    StringGetPos, pos, CPU, %Perc%    If (pos = 14) or ((pos = 19) and (CN = "T"))     {      CPU100 := 1      If (SS = "C98") or (SS = "M")       Process, Priority, %scrPID%, AboveNormal      CPUlim := CPUlim+1     }    else     {      If (CN <> "T")       StringMid, CPUU, CPU, 13, 2, L      else StringMid, CPUU, CPU, 18, 2, L      If (CPUU > 90)       {        CPU100 := 1        CPUlim := CPUlim+1        CuDa := A_YYYY A_MM A_DD        CuTi := A_Hour A_Min A_Sec        FileAppend, CPUU ¦ %CuDa%@%CuTi% ¦ %CPUU% ¦ SS:%SS% ¦ CPUlim:%CPUlim% `n, %PFa%\ahk\%CN%%SNt2%.txt       }      else CPU100 := 0     }which can be used to test for CPU usage (CPUU) at 100 or 90 or any %;

I have but do not often use the SysIntern ProX.
I (like IainB & StoicJo) started watching the XP WTM
(I have always sorted like StoicJo posted) a long time ago -
mostly because I hate trying to work on an unresponsive computer.

The PC is largely unresponsive to the user & processes in general when CPUU is 100%.
(I have never found the trick of lowering the priority of the resource hog to be effective.
 Lowering the priority allows other exes to grap CPUU but does not lower CPUU from 100%,

If there is interest I could post some other WTM-related scripts.
These other scripts mostly (re-)position the XP WTM.
I always have the XP WTM open & in the lower right corner.
One of my AHK scripts short-circuits/supercharges my XP "AppsKey" (AK).
For example, when the XP WTM is active & I hit the AK,
the script(s) will reposition the the XP WTM various ways ...»
WTMin
WTMin is for when I want the XP WTM to take up the least screen real estate ...
WTMreg
WTMreg is for when the XP WTM doesn't need to be minimized/maximized ...
All I need to do is Alt-Tab to the WTM & then Ctrl-(Shift)-Tab between the Task/Processes/Summary ...
WTMax
WTMmax is for when I need to maximize the XP WTM  ...

In any case, the CPUtimes script reports the CPU usage to a TrayTip - not a variable.
I'm hoping to see a script example of how to have the CPU usage
of the active window reported to a variable ...-AEN007 (November 08, 2011, 02:17 AM)
--- End quote ---
The GetProcessTimes(), GetSystemTimes() and GetIdleTimes() functions in that script return the data you want.  It's up to you dump that data into a variable:
--- Code: Autohotkey ---myVar := GetSystemTimes(); myVar will now contain the total CPU load at that moment.; Now do whatever you need to do with the variable and data.-skwire (November 08, 2011, 02:34 AM)
--- End quote ---
Greetings & thanks for the reply ...
I have already been trying to do what you have posted,
but it has not been working for me.
I can get from the XP WTM what GetSystemTimes provides.
I want to put GetProcessTimes into a variable at any given moment.
I have used Sean's TrayIcons() & TaskButtons() in many scripts, like ...
--- Code: Autohotkey ---If (WxX = 0) {  TBEE := TaskButtons("explorer.exe")  StringSplit, TBV, TBEE,|  idn :=  RegExReplace(TBV2, "idn: ")  StringTrimRight, idnT, idn, 1  idnNWC := idnT  HideButton(idnNWC, False)  SLEEP, %Slb%  HideButton(idnNWC, True) }Those TrayIcons() & TaskButtons script/functions reside in the AHK\Lib "PATH".
I should be able to access/use CPUTimes.ahk the same way, ja?

I have already tried the following»

--- Code: Autohotkey ---WinGet, AWpid, PID, AGPTpid := AWpidMsgBox, 0, GPTpid, %GPTpid%GST := GetSystemTimes()MsgBox, 0, GST, %GST%GPT := GetProcessTimes(GPTpid)MsgBox, 0, GPT, %GPT%GST & GPT are always blank ...
Any helpful replies/insights appreciated ...

AEN007:
2December2011
Still hoping for a solution.
Any helpful replies/insights appreciated ...

AEN007:
2December2011
Still hoping for a solution.
Any helpful replies/insights appreciated ...-AEN007 (December 02, 2011, 07:16 AM)
--- End quote ---

AEN007:
25June2012

Greetings.

Well, today I FINALLY worked out how to use GetProcessTimes (GPT) in an AHK script.
Many thanks to Skwire for the reply with the link to the AHK forum thread ...

However, from what I can tell, GPT does not retrieve CPU usage values
that are in any way close to those reported by Windows Task Manager,
and half the time or more often GPT retrieves a CPU usage value of zero ...
There is probably no need to elaborate ...

I searched the web with "autohotkey process cpu usage" and
found an AHK forum thread with some code that uses»
ControlGet, var, List, , SysListView321, Windows Task ahk_class #32770.
I came up with some quicker/simpler code that will allow my AHK scripts
to determine the (WTM) CPU usage of any running process ...
so unless there is some discussion (of value) to follow,
I guess I am finished with this thread ...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version