Sign in to follow this  
Followers 0
shockwaveaz

Newbie needs help. Thanks

2 posts in this topic

This is my first script so please be kind but much help is needed. I want to show processor use % for a single process such as "idle" but I cant figure out how to call a single object from the ouput and of course my code is a mess so any help would be appreciated. I have looked at other examples but still cant figure it out...

CODE
#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <GuiEdit.au3>

HotKeySet("^!x", "MyExit")

$Form1 = GUICreate("Process", 75, 25, 125, 125)

$Edit1 = GUICtrlCreateEdit("", 0, 0, 613, 369, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL))

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetBkColor(-1, 0x000000)

_GUICtrlEdit_SetReadOnly($Edit1, True)

$Exit = GUICtrlCreateButton("Exit", 540, 416, 75, 25, 0)

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUISetState(@SW_SHOW)

$nMsg = GUIGetMsg()

$THRESHOLD = 0

ConsoleWrite($THRESHOLD)

$WBEMFLAGRETURNIMMEDIATELY = 16

$WBEMFLAGFORWARDONLY = 32

$COLITEMS = ""

$OBJWMISERVICE = ObjGet("winmgmts:\\localhost\root\CIMV2")

$OUTMAX = 0

$LASTOUT = 0

$HDC = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)

While 1

$COLITEMS = $OBJWMISERVICE.ExecQuery("SELECT PercentProcessorTime FROM Win32_PerfRawData_PerfProc_Thread", "wql", $WBEMFLAGRETURNIMMEDIATELY + $WBEMFLAGFORWARDONLY)

If IsObj($COLITEMS) Then

For $OBJITEM In $COLITEMS

$NEWOUT = $OBJITEM.PercentProcessorTime

If $LASTOUT = 0 Then $LASTOUT = $NEWOUT

$OUT = $NEWOUT - $LASTOUT

$LASTOUT = $NEWOUT

If $OUT > $THRESHOLD Then

GUICtrlSetData($Edit1, $OUT)

EndIf

ExitLoop

Next

EndIf

Sleep(1000)

WEnd

Func MyExit()

Exit

EndFunc

Share this post


Link to post
Share on other sites



This is my first script so please be kind but much help is needed. I want to show processor use % for a single process such as "idle" but I cant figure out how to call a single object from the ouput and of course my code is a mess so any help would be appreciated. I have looked at other examples but still cant figure it out...

You could just call _ProcessListProperties().

The function is complete and there is a demo script in the topic to show how to use it to display properties (including CPU and memory usage) for all processes or just one process.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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