guwguw Posted April 18, 2013 Posted April 18, 2013 I am dealing with a Java application, which creates multiple versions of a named window. The named windows give a result of 0 (zero) when called ConsoleWrite("!+ " & @ScriptLineNumber & " " & FileGetSize(WinGetProcess("javaw.exe" ,"")) & @CRLF) Requesting $list = ProcessGetStats("javaw.exe",1) _ArrayDisplay($list, @ScriptLineNumber & " " & $list) delivers the expected results, but not the size as posted in the fifth column of the task manager list. The PID handle is easy to get with WinGetHandle("xyzabc - era", ""), but I cannot find a way to get the matching size. Does anyone know a way?
guinness Posted April 18, 2013 Posted April 18, 2013 Look at the return values of those functions and you will see why it doesn't work. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Nessie Posted April 19, 2013 Posted April 19, 2013 (edited) You can do something like that: Run("notepad.exe") WinWait("[CLASS:Notepad]") $pid = WinGetProcess("[CLASS:Notepad]") $path = _ProcessGetLocation($pid) If @error Then MsgBox(0, "Error", "Unable to get the process location") Exit EndIf ConsoleWrite("Process path: " & $path & @CRLF) ;Debug only $size = FileGetSize($path) MsgBox(0, "", "The size is: " & $size & "bytes.") Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation Hi! Edited April 19, 2013 by Nessie My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file
guwguw Posted April 19, 2013 Author Posted April 19, 2013 (edited) You can do something like that: Run("notepad.exe") WinWait("[CLASS:Notepad]") $pid = WinGetProcess("[CLASS:Notepad]") $path = _ProcessGetLocation($pid) If @error Then MsgBox(0, "Error", "Unable to get the process location") Exit EndIf ConsoleWrite("Process path: " & $path & @CRLF) ;Debug only $size = FileGetSize($path) MsgBox(0, "", "The size is: " & $size & "bytes.") Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation Hi! Nessie, your approach seemed promising at first. But since the Func _ProcessGetLocation($iPID) is pretty much a mystery to me, I cannot deduct the desired value (I'm not after the file size!). Your utility reports "The size of C:\Windows\System32\notepad.exe is: 70144 bytes." - which is the file size of Notepad, not the size of the memory space it operates in, reported by Windows Task Manager as size of 2.944 k in the fifths column (here it's titled "Speicherauslastung") - sorry if I caused a confusion here, but "Speicherauslastung" was translated by Google as "size". guinness, During my research, I had come across (your?) Func _WinGetDetails($sTitle, $sText = '') and tried to adapt it to deliver that fifth column value, but did not succeed. I tried to follow your advice "Look at the return values of those functions and you will see why it doesn't work." ... to no avail! What can I deduct from a zero? It reads like "Eat an egg and you will know why it's not a chicken." Edited April 19, 2013 by guwguw
guinness Posted April 19, 2013 Posted April 19, 2013 Nessie assumed what we all thought. Look at MemGetStats. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
guwguw Posted April 19, 2013 Author Posted April 19, 2013 Look at MemGetStats.Is it possible to extract the desired value via MemGetStats?I only managed to get overall system memory info from it, nothing in relation to single processes.
guinness Posted April 19, 2013 Posted April 19, 2013 My mistake. Look at _WinAPI_GetProcessMemoryInfo in WinAPIEx. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
guwguw Posted April 19, 2013 Author Posted April 19, 2013 Look at _WinAPI_GetProcessMemoryInfo in WinAPIEx.I getNumber of page faults: 4210Peak working set size: 15052800 bytesCurrent working set size: 15052800 bytesPeak paged pool usage: 74772 bytesCurrent paged pool usage: 61788 bytesPeak nonpaged pool usage: 3128 bytesCurrent nonpaged pool usage: 2800 bytesCurrent space allocated for the pagefile: 12775424 bytesPeak space allocated for the pagefile: 12775424 bytesCurrent private space: 12775424 bytesstill nothing process-related.I think I'll give up this route (AutoIt) and get the desired data via OCR of the Task Manager or a direct memory-read ...The underlying problem is a Java trading program that used to perform for an entire week uninterruptedly without problem.During the last two years there were a lot of programmer changes (at the program company) who added not functions, but obviously a lot of debugging information, bloating the software to a level, where I have to unload and reload the program about every two hours to prevent it from freezing the trading interface.My goal is to automate the refreshing cycles before the affected parts reach their critical limits.
guinness Posted April 19, 2013 Posted April 19, 2013 Look around then for WMI. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
BrewManNH Posted April 19, 2013 Posted April 19, 2013 If I'm not mistaken, that information you posted about the return from _WinAPI_GetProcessMemoryInfo gives you exactly what you were asking about doesn't it? Isn't the Working Set the memory info you're looking for? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Nessie Posted April 19, 2013 Posted April 19, 2013 (edited) This should do the trick: expandcollapse popup#include <WinAPI.au3> Run("notepad.exe") WinWait("[CLASS:Notepad]") $PID = WinGetProcess("[CLASS:Notepad]") $size = _WinAPI_GetProcessMemoryInfo($PID) If Not @error Then $size = $size / 1024 Else MsgBox(16, "Error", "Unable to retrive the used memory") Exit EndIf MsgBox(0, "", "The size is: " & $size & "KB") Func _GetDisplaySize($iSize, $iPlaces = 2) Local $aBytes[5] = [' Bytes', ' KB', ' MB', ' GB', ' TB'] For $i = 4 To 1 Step -1 If $iSize >= 1024 ^ $i Then Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i] EndIf Next Return $iSize & ' Bytes' EndFunc ;==>_GetDisplaySize Func _WinAPI_GetProcessMemoryInfo($PID = 0) ;Taken from WinAPIEx modified by Nessie Local $__WINVER = __WINVER() If Not $PID Then $PID = @AutoItPID EndIf Local $hProcess = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'dword', __Iif($__WINVER < 0x0600, 0x00000410, 0x00001010), 'int', 0, 'dword', $PID) If (@error) Or (Not $hProcess[0]) Then Return SetError(1, 0, 0) EndIf Local $tPMC_EX = DllStructCreate('dword;dword;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr;ulong_ptr') Local $Ret = DllCall(@SystemDir & '\psapi.dll', 'int', 'GetProcessMemoryInfo', 'ptr', $hProcess[0], 'ptr', DllStructGetPtr($tPMC_EX), 'int', DllStructGetSize($tPMC_EX)) If (@error) Or (Not $Ret[0]) Then $Ret = 0 EndIf _WinAPI_CloseHandle($hProcess[0]) If Not IsArray($Ret) Then Return SetError(1, 0, 0) EndIf Local $Result = DllStructGetData($tPMC_EX, 4) Return $Result EndFunc ;==>_WinAPI_GetProcessMemoryInfo Func __WINVER() Local $tOSVI = DllStructCreate('dword;dword;dword;dword;dword;wchar[128]') DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $Ret = DllCall('kernel32.dll', 'int', 'GetVersionExW', 'ptr', DllStructGetPtr($tOSVI)) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3)) EndFunc ;==>__WINVER Func __Iif($fTest, $iTrue, $iFalse) If $fTest Then Return $iTrue Else Return $iFalse EndIf EndFunc ;==>__Iif Hi! Edited April 19, 2013 by Nessie My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file
UEZ Posted April 20, 2013 Posted April 20, 2013 Here the code which I'm using to determine the amount of memory which uses Iron. expandcollapse popup#include <Array.au3> Global $sInput = InputBox("Process Memory Usage", "Enter a proces name", "Iron.exe", "", 250, 130) If @error Or Not $sInput Then Exit Global Const $sProcessName = "Iron.exe" Global Const $aProcessList = ProcessList($sProcessName) If Not $aProcessList[0][0] Then Exit MsgBox(16, "Error", "No process found with the name " & $sInput, 30) Global Const $Process_All_Access = 0x1F0FFF Global $iMem1 = 0, $iMem2 = 0 For $i = 1 To $aProcessList[0][0] $ProcHandle = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $Process_All_Access, "int", False, "dword", $aProcessList[$i][1]) $iMem1 += _WinAPI_GetProcessMemoryInfo($ProcHandle[0]) $iMem2 += _WinAPI_GetProcessMemoryInfo($ProcHandle[0], "PrivateUsage") Next MsgBox(0, "Mem Usage", "Iron Total Mem Usage (working set): " & Round($iMem1 / 1024^3, 2) & " GB" & @LF & _ "Iron Total Mem Usage (private bytes): " & Round($iMem2 / 1024^3, 2) & " GB") Exit Func _WinAPI_GetProcessMemoryInfo($hProcess, $sMemType = "WorkingSize") ;get physical memory of the process -> http://msdn.microsoft.com/en-us/library/ms683219%28VS.85%29.aspx Local $tPROCESS_MEMORY_COUNTERS, $tPROCESS_MEMORY_COUNTERS_EX, $nSize, $aRet If @OSBuild < 7600 Then $tPROCESS_MEMORY_COUNTERS = DllStructCreate( _ ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx "dword cb; dword PageFaultCount; dword_ptr PeakWorkingSetSize; dword_ptr WorkingSetSize; " & _ "dword_ptr QuotaPeakPagedPoolUsage; dword_ptr QuotaPagedPoolUsage; dword_ptr QuotaPeakNonPagedPoolUsage; " & _ "dword_ptr QuotaNonPagePoolUsage; dword_ptr PagefileUsage; dword_ptr PeakPagefileUsage") $nSize = DllStructGetSize($tPROCESS_MEMORY_COUNTERS) $aRet = DllCall("psapi.dll", "int", "GetProcessMemoryInfo", "handle", $hProcess, "struct*", $tPROCESS_MEMORY_COUNTERS, "dword", $nSize) ;call GetProcessMemoryInfo If $aRet[0] = 0 Then SetError(1, 0, $aRet[0]) EndIf Return DllStructGetData($tPROCESS_MEMORY_COUNTERS, "WorkingSetSize") Else $tPROCESS_MEMORY_COUNTERS_EX = DllStructCreate( _ ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx "dword cb; dword PageFaultCount; dword_ptr PeakWorkingSetSize; dword_ptr WorkingSetSize; " & _ "dword_ptr QuotaPeakPagedPoolUsage; dword_ptr QuotaPagedPoolUsage; dword_ptr QuotaPeakNonPagedPoolUsage; " & _ "dword_ptr QuotaNonPagePoolUsage; dword_ptr PagefileUsage; dword_ptr PeakPagefileUsage; " & _ "dword_ptr PrivateUsage") $nSize = DllStructGetSize($tPROCESS_MEMORY_COUNTERS_EX) $aRet = DllCall("Kernel32.dll", "int", "K32GetProcessMemoryInfo", "handle", $hProcess, "struct*", $tPROCESS_MEMORY_COUNTERS_EX, "dword", $nSize) ;call GetProcessMemoryInfo If $aRet[0] = 0 Then SetError(1, 0, $aRet[0]) EndIf Switch $sMemType Case "PrivateUsage" Return DllStructGetData($tPROCESS_MEMORY_COUNTERS_EX, "PrivateUsage") Case "WorkingSize" Return DllStructGetData($tPROCESS_MEMORY_COUNTERS_EX, "WorkingSetSize") EndSwitch EndIf EndFunc ;==>_WinAPI_GetProcessMemoryInfo Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
guinness Posted April 20, 2013 Posted April 20, 2013 Nessie, I don't really condone stripping from WinAPIEx unless you put a warning that it might cause problems if you use WinAPIEx. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Nessie Posted April 20, 2013 Posted April 20, 2013 Nessie,I don't really condone stripping from WinAPIEx unless you put a warning that it might cause problems if you use WinAPIEx.You are right, but that was only an example And if he uses in his script the function _WinAPI_GetProcessMemoryInfo() modified by me in the example in association with #include <WinAPIEx.au3>, Scite will warn him because the function is already used by WinAPIEx.au3.BTW every your advice is welcome , so let's drink a beer together Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file
kylomas Posted April 21, 2013 Posted April 21, 2013 guwguw, I get Number of page faults: 4210 Peak working set size: 15052800 bytes Current working set size: 15052800 bytes Peak paged pool usage: 74772 bytes Current paged pool usage: 61788 bytes Peak nonpaged pool usage: 3128 bytes Current nonpaged pool usage: 2800 bytes Current space allocated for the pagefile: 12775424 bytes Peak space allocated for the pagefile: 12775424 bytes Current private space: 12775424 bytes still nothing process-related. Not True...see the following code expandcollapse popup#include <guiconstants.au3> #include <windowsconstants.au3> #include <guilistview.au3> #include <winapiex.au3> #include <process.au3> local $hdr = '# PF|P-WS|C-WS|P-PPU|C-PPU|P-NPPU|C-NPPU|C-Page|P-Page|C-XMEM' local $gui010 = guicreate('Memory Usage Monitor for PID = ' & @autoitpid,1100,800) local $aSize = wingetclientsize($gui010) guictrlcreatelabel('Memory Stats for Process = ' & _processgetname(@autoitpid),10,20,400,30) guictrlsetfont(-1,12,800) local $lst010 = GUICtrlCreateListView($hdr,10,50,$aSize[0]-20,$aSize[1]-150) local $aLVSize = controlgetpos($gui010,'',$lst010) guictrlcreatelabel(' * - See the Help File for a definition of what each column means',10,$aSize[1]-80,$aSize[0]-20,150) guictrlsetfont(-1,10,800,default,'courier new') for $1 = 0 to _GUICtrlListView_GetColumnCount($lst010) + 1 _GUICtrlListView_SetColumnWidth($lst010, $1, $aLVSize[2]/_GUICtrlListView_GetColumnCount($lst010)) next guisetstate() adlibregister('_logmem',3000) while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd func _logmem() local $aMem = _winapi_getprocessmemoryinfo(@autoitpid) if $aMem = 0 then ConsoleWrite('Error in getprocessmemoryinfo' & @LF) local $lv_str = '' for $1 = 0 to ubound($aMem) - 1 $lv_str &= $aMem[$1] & '|' next $lv_str = stringtrimright($lv_str,1) guictrlcreatelistviewitem($lv_str, $lst010) endfunc (as BrewManNH suggested) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
kylomas Posted April 21, 2013 Posted April 21, 2013 (edited) guwguw, This shows more clearly that process specific stats are being returned expandcollapse popup#include <guiconstants.au3> #include <windowsconstants.au3> #include <guilistview.au3> #include <winapiex.au3> #include <process.au3> local $hdr = 'Process Name|PID|# PF|P-WS|C-WS|P-PPU|C-PPU|P-NPPU|C-NPPU|C-Page|P-Page|C-XMEM' local $gui010 = guicreate('Memory Usage Monitor',1200,800) local $aSize = wingetclientsize($gui010) local $lst010 = GUICtrlCreateListView($hdr,10,50,$aSize[0]-20,$aSize[1]-150) guictrlsetfont(-1,8,600,default,'lucinda console') local $aLVSize = controlgetpos($gui010,'',$lst010) guictrlcreatelabel(' * - See the Help File for a definition of what each column means',10,$aSize[1]-80,$aSize[0]-20,150) guictrlsetfont(-1,10,800,default,'courier new') for $1 = 0 to _GUICtrlListView_GetColumnCount($lst010) + 1 _GUICtrlListView_SetColumnWidth($lst010, $1, $aLVSize[2]/_GUICtrlListView_GetColumnCount($lst010)) next guisetstate() adlibregister('_logmem',2000) _logmem() while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd func _logmem() if _GUICtrlListView_DeleteAllItems(guictrlgethandle($lst010)) = false then ConsoleWrite('delete items failed' & @LF) Exit endif local $apids = processlist(), $lv_str = '', $amem ;~ _arraydisplay($apids) ;~ exit for $1 = 1 to $apids[0][0] $lv_str = '' $lv_str &= $apids[$1][0] & '|' $lv_str &= $apids[$1][1] & '|' $aMem = _winapi_getprocessmemoryinfo($apids[$1][1]) if $aMem = 0 then continueloop for $2 = 0 to ubound($aMem) - 1 $lv_str &= $aMem[$2] & '|' next $lv_str = stringtrimright($lv_str,1) guictrlcreatelistviewitem($lv_str, $lst010) ;msgbox(0,'','') next endfunc kylomas Edited April 21, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now