Sign in to follow this  
Followers 0
jercfd

ProcessGetStats array problem

3 posts in this topic

Can someone please help me with an array problem. I can't seem to get the ProcessGetStats array working.

$Process = ProcessList()
For $i = 1 To $Process[0][0]
    FileWriteLine($ScriptSaveDir, "Process Name: " & $Process[$i][0])
    FileWriteLine($ScriptSaveDir, "Process PID: " & $Process[$i][1])
    $ProcessMemStats = ProcessGetStats($Process[$i][1], 0)
    $ProcessIOStats = ProcessGetStats($Process[$i][1], 1)
    FileWriteLine($ScriptSaveDir, "Working Set Size: " & $ProcessMemStats[0])
    FileWriteLine($ScriptSaveDir, "Peak Working Set Size: " & $ProcessMemStats[1])
    FileWriteLine($ScriptSaveDir, "Read Operations Performed: " & $ProcessIOStats[0])
    FileWriteLine($ScriptSaveDir, "Write Operations Performed: " & $ProcessIOStats[1])
    FileWriteLine($ScriptSaveDir, "I/O Operations Performed: " & $ProcessIOStats[2])
    FileWriteLine($ScriptSaveDir, "Bytes Read: " & $ProcessIOStats[3])
    FileWriteLine($ScriptSaveDir, "Bytes Write: " & $ProcessIOStats[4])
    FileWriteLine($ScriptSaveDir, "Bytes Transferred : " & $ProcessIOStats[5])
Next

Error Recieved

>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Ming Wu\Desktop\Testing.au3"    
C:\Documents and Settings\Ming Wu\Desktop\Testing.au3 (104) : ==> Subscript used with non-Array variable.: 
FileWriteLine($ScriptSaveDir, "Working Set Size: " & $ProcessMemStats[0]) 
FileWriteLine($ScriptSaveDir, "Working Set Size: " & $ProcessMemStats^ ERROR
->21:27:25 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 1.641

Share this post


Link to post
Share on other sites



Not all processes will returm\n the info you are looking for with ProcessGetStats().

This works

$Process = ProcessList()

For $i = 1 To Ubound($process)-1
    MsgBox(0, "Test", "Process Name: " & $Process[$i][0])
    MsgBox(0, "Test", "Process PID: " & $Process[$i][1])
    $ProcessMemStats = ProcessGetStats($Process[$i][1], 0)
    $ProcessIOStats = ProcessGetStats($Process[$i][1], 1)
    If IsArray($ProcessMemStats) Then
       MsgBox(0, "Test", "Working Set Size: " & $ProcessMemStats[0])
       MsgBox(0, "Test", "Peak Working Set Size: " & $ProcessMemStats[1])
    EndIf
    If IsArray($ProcessIOStats) Then
       MsgBox(0, "Test", "Read Operations Performed: " & $ProcessIOStats[0])
       MsgBox(0, "Test", "Write Operations Performed: " & $ProcessIOStats[1])
       MsgBox(0, "Test", "I/O Operations Performed: " & $ProcessIOStats[2])
       MsgBox(0, "Test", "Bytes Read: " & $ProcessIOStats[3])
       MsgBox(0, "Test", "Bytes Write: " & $ProcessIOStats[4])
       MsgBox(0, "Test", "Bytes Transferred : " & $ProcessIOStats[5])
    EndIf
 Next

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Not all processes will returm\n the info you are looking for with ProcessGetStats().

This works

$Process = ProcessList()

For $i = 1 To Ubound($process)-1
    MsgBox(0, "Test", "Process Name: " & $Process[$i][0])
    MsgBox(0, "Test", "Process PID: " & $Process[$i][1])
    $ProcessMemStats = ProcessGetStats($Process[$i][1], 0)
    $ProcessIOStats = ProcessGetStats($Process[$i][1], 1)
    If IsArray($ProcessMemStats) Then
       MsgBox(0, "Test", "Working Set Size: " & $ProcessMemStats[0])
       MsgBox(0, "Test", "Peak Working Set Size: " & $ProcessMemStats[1])
    EndIf
    If IsArray($ProcessIOStats) Then
       MsgBox(0, "Test", "Read Operations Performed: " & $ProcessIOStats[0])
       MsgBox(0, "Test", "Write Operations Performed: " & $ProcessIOStats[1])
       MsgBox(0, "Test", "I/O Operations Performed: " & $ProcessIOStats[2])
       MsgBox(0, "Test", "Bytes Read: " & $ProcessIOStats[3])
       MsgBox(0, "Test", "Bytes Write: " & $ProcessIOStats[4])
       MsgBox(0, "Test", "Bytes Transferred : " & $ProcessIOStats[5])
    EndIf
 Next
Thank You. This works for my script.

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