Jump to content

Processor Usage


cramaboule
 Share

Recommended Posts

As my PC is getting old and being busy I like to Follow up the CPU usage without always having the task manager open.

In the zip file you have Icons and au3.

Enjoy !

Cramaboule !

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=11.ICO
#AutoIt3Wrapper_Res_Description=Processor By Cramaboule
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Freeware
#AutoIt3Wrapper_Res_Icon_Add=0.ICO
#AutoIt3Wrapper_Res_Icon_Add=1.ICO
#AutoIt3Wrapper_Res_Icon_Add=2.ICO
#AutoIt3Wrapper_Res_Icon_Add=3.ICO
#AutoIt3Wrapper_Res_Icon_Add=4.ICO
#AutoIt3Wrapper_Res_Icon_Add=5.ICO
#AutoIt3Wrapper_Res_Icon_Add=6.ICO
#AutoIt3Wrapper_Res_Icon_Add=7.ICO
#AutoIt3Wrapper_Res_Icon_Add=8.ICO
#AutoIt3Wrapper_Res_Icon_Add=9.ICO
#AutoIt3Wrapper_Res_Icon_Add=10.ICO
#AutoIt3Wrapper_Res_Icon_Add=11.ICO
#AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

$PList = ProcessList("processor.exe")
If $PList[0][0] > 1 Then Exit

#include <Constants.au3>
;#include <array.au3>

#Region Global Variables and Constants

Global $cI_CompName = @ComputerName
Global Const $cI_VersionInfo = "00.03.08"
Global Const $cI_aName = 0, _
        $cI_aDesc = 4
Global $wbemFlagReturnImmediately = 0x10, _ ;DO NOT CHANGE
        $wbemFlagForwardOnly = 0x20 ;DO NOT CHANGE
Global $ERR_NO_INFO = "Array contains no information", _
        $ERR_NOT_OBJ = "$colItems isnt an object"
#EndRegion Global Variables and Constants


Global $proc, $Process


Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
$exititem = TrayCreateItem("Exit")
TrayItemSetState($exititem, $TRAY_DEFAULT)
TraySetState()
TraySetClick(16)
$Init = TimerInit()
$j = 1
While 1
    If TimerDiff($Init) > 1000 Or $j = 1 Then
        _ComputerGetProcessors($proc)
        $i = Int($proc[1][21] / (8.34))
        ;icon 5 = 0%
        ;icon 16 = 100%
        TraySetToolTip("UC Usage: " & $proc[1][21] & "%")
        If @Compiled Then
            $path = @ScriptFullPath
        Else
            $path = @ScriptDir & "\processor.exe"
        EndIf
        TraySetIcon($path, (-1 * ($i + 5)))
        $Init = TimerInit()
        $j = 0
    EndIf
    $traymsg = TrayGetMsg()
    If $traymsg = $exititem Then Exit
WEnd




;===============================================================================
; Description:  Returns the Processor information in an array.
; Parameter(s):     $aProcessorInfo - By Reference - Processor Information array.
; Requirement(s): None
; Return Value(s): On Success - Returns array of Processor Information.
;                       $aProcessorInfo[0][0] = Number of Processors
;                       $aProcessorInfo[$i][0] = Name ($i starts at 1)
;                       $aProcessorInfo[$i][1] = Address Width
;                       $aProcessorInfo[$i][2] = Architecture
;                       $aProcessorInfo[$i][3] = Availability
;                       $aProcessorInfo[$i][4] = Description
;                       $aProcessorInfo[$i][5] = Config Manager Error Code
;                       $aProcessorInfo[$i][6] = Config Manager User Config
;                       $aProcessorInfo[$i][7] = CPU Status
;                       $aProcessorInfo[$i][8] = Creation Class Name
;                       $aProcessorInfo[$i][9] = Current Clock Speed
;                       $aProcessorInfo[$i][10] = Current Voltage
;                       $aProcessorInfo[$i][11] = Data Width
;                       $aProcessorInfo[$i][12] = Device ID
;                       $aProcessorInfo[$i][13] = Error Cleared
;                       $aProcessorInfo[$i][14] = Error Description
;                       $aProcessorInfo[$i][15] = Ext Clock
;                       $aProcessorInfo[$i][16] = Family
;                       $aProcessorInfo[$i][17] = L2 Cache Size
;                       $aProcessorInfo[$i][18] = L2 Cache Speed
;                       $aProcessorInfo[$i][19] = Last Error Code
;                       $aProcessorInfo[$i][20] = Level
;                       $aProcessorInfo[$i][21] = Load Percentage
;                       $aProcessorInfo[$i][22] = Manufacturer
;                       $aProcessorInfo[$i][23] = Max Clock Speed
;                       $aProcessorInfo[$i][24] = Other Family Description
;                       $aProcessorInfo[$i][25] = PNP Device ID
;                       $aProcessorInfo[$i][26] = Power Management Capabilities
;                       $aProcessorInfo[$i][27] = Power Management Supported
;                       $aProcessorInfo[$i][28] = Processor ID
;                       $aProcessorInfo[$i][29] = Processor Type
;                       $aProcessorInfo[$i][30] = Revision
;                       $aProcessorInfo[$i][31] = Role
;                       $aProcessorInfo[$i][32] = Socket Designation
;                       $aProcessorInfo[$i][33] = Status
;                       $aProcessorInfo[$i][34] = Status Info
;                       $aProcessorInfo[$i][35] = Stepping
;                       $aProcessorInfo[$i][36] = System Creation Class Name
;                       $aProcessorInfo[$i][37] = System Name
;                       $aProcessorInfo[$i][38] = Unique ID
;                       $aProcessorInfo[$i][39] = Upgrade Method
;                       $aProcessorInfo[$i][40] = Version
;                       $aProcessorInfo[$i][41] = Voltage Caps
;   On Failure - @error = 1 and Returns 0
;                               @extended = 1 - Array contains no information
;                                           2 - $colItems isnt an object
; Author(s):    Jarvis Stubblefield (support "at" vortexrevolutions "dot" com)
; Note(s):
;===============================================================================
Func _ComputerGetProcessors(ByRef $aProcessorInfo)
    Local $colItems, $objWMIService, $objItem, $i = 1
    Dim $aProcessorInfo[1][42]

    $objWMIService = ObjGet("winmgmts:\\" & $cI_CompName & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            ReDim $aProcessorInfo[UBound($aProcessorInfo) + 1][42]
            $aProcessorInfo[$i][0] = StringStripWS($objItem.Name, 1)
            $aProcessorInfo[$i][1] = $objItem.AddressWidth
            $aProcessorInfo[$i][2] = $objItem.Architecture
            $aProcessorInfo[$i][3] = $objItem.Availability
            $aProcessorInfo[$i][4] = $objItem.Description
            $aProcessorInfo[$i][5] = $objItem.ConfigManagerErrorCode
            $aProcessorInfo[$i][6] = $objItem.ConfigManagerUserConfig
            $aProcessorInfo[$i][7] = $objItem.CpuStatus
            $aProcessorInfo[$i][8] = $objItem.CreationClassName
            $aProcessorInfo[$i][9] = $objItem.CurrentClockSpeed
            $aProcessorInfo[$i][10] = $objItem.CurrentVoltage
            $aProcessorInfo[$i][11] = $objItem.DataWidth
            $aProcessorInfo[$i][12] = $objItem.DeviceID
            $aProcessorInfo[$i][13] = $objItem.ErrorCleared
            $aProcessorInfo[$i][14] = $objItem.ErrorDescription
            $aProcessorInfo[$i][15] = $objItem.ExtClock
            $aProcessorInfo[$i][16] = $objItem.Family
            $aProcessorInfo[$i][17] = $objItem.L2CacheSize
            $aProcessorInfo[$i][18] = $objItem.L2CacheSpeed
            $aProcessorInfo[$i][19] = $objItem.LastErrorCode
            $aProcessorInfo[$i][20] = $objItem.Level
            $aProcessorInfo[$i][21] = $objItem.LoadPercentage
            $aProcessorInfo[$i][22] = $objItem.Manufacturer
            $aProcessorInfo[$i][23] = $objItem.MaxClockSpeed
            $aProcessorInfo[$i][24] = $objItem.OtherFamilyDescription
            $aProcessorInfo[$i][25] = $objItem.PNPDeviceID
            $aProcessorInfo[$i][26] = $objItem.PowerManagementCapabilities(0)
            $aProcessorInfo[$i][27] = $objItem.PowerManagementSupported
            $aProcessorInfo[$i][28] = $objItem.ProcessorId
            $aProcessorInfo[$i][29] = $objItem.ProcessorType
            $aProcessorInfo[$i][30] = $objItem.Revision
            $aProcessorInfo[$i][31] = $objItem.Role
            $aProcessorInfo[$i][32] = $objItem.SocketDesignation
            $aProcessorInfo[$i][33] = $objItem.Status
            $aProcessorInfo[$i][34] = $objItem.StatusInfo
            $aProcessorInfo[$i][35] = $objItem.Stepping
            $aProcessorInfo[$i][36] = $objItem.SystemCreationClassName
            $aProcessorInfo[$i][37] = $objItem.SystemName
            $aProcessorInfo[$i][38] = $objItem.UniqueId
            $aProcessorInfo[$i][39] = $objItem.UpgradeMethod
            $aProcessorInfo[$i][40] = $objItem.Version
            $aProcessorInfo[$i][41] = $objItem.VoltageCaps
            $i += 1
        Next
        $aProcessorInfo[0][0] = UBound($aProcessorInfo) - 1
        If $aProcessorInfo[0][0] < 1 Then
            SetError(1, 1, 0)
        EndIf
    Else
        SetError(1, 2, 0)
    EndIf
EndFunc ;==>_ComputerGetProcessors

processor.zip

Link to comment
Share on other sites

Why not show all the features of the processor?

Well... this Function is part of CompInfo.au3.

I just took out _ComputerGetProcessors() function.

And my purpose is only to see the CPU usage

Cramaboule.;)

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