trancexx Posted October 23, 2010 Share Posted October 23, 2010 I know from where that was (and I know what I posted). ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Ascend4nt Posted October 23, 2010 Share Posted October 23, 2010 Riiight. Maybe you should actually read the book now that you're aware of it. There's no 'free interpretation' of unions in there. By the way, why add AutoItObject to this? kiboost didn't want to use my UDF because it was 'huge'. That'd be an understatement for AutoIt object. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
iamtheky Posted October 23, 2010 Share Posted October 23, 2010 i believe i've followed the wmi examples but i still return a couple of problems 1) it seems i am in hundreds when i should be in the tens 2) but changing the 100 to a * 10 only highlights the greater issue in that it seems a fairly static number and unrelated to cpu usage. expandcollapse popupwhile 1 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_PerfProc_Process", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objitem.name = "_Total" Then $Proc1 = $objItem.PercentProcessorTime $Stamp1 = $objItem.Timestamp_Sys100NS EndIf next EndIf sleep (2000) $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_PerfProc_Process", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objitem.name = "_Total" Then $Proc2 = $objItem.PercentProcessorTime $Stamp2 = $objItem.Timestamp_Sys100NS EndIf next EndIf $Procd = $Proc2 - $Proc1 $Stampd = $Stamp2 - $Stamp1 $final = ($procd/$stampd) * 100 tooltip ("CPU USAGE: " & $final, 0, 0) sleep (1000) wend ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
trancexx Posted October 23, 2010 Share Posted October 23, 2010 (edited) Riiight. Maybe you should actually read the book now that you're aware of it. There's no 'free interpretation' of unions in there.By the way, why add AutoItObject to this? kiboost didn't want to use my UDF because it was 'huge'. That'd be an understatement for AutoIt object.Don't riiight me please. I thought we passed that level of interaction.When was that book published? When Microsoft released first 64bit system? Find "64bit systems", or even better -windows 7- chapter in that book and read about definitions of that structure(s).AutoItObject is there to show that earth is not flat. I wasn't aiming kiboost. Edited October 23, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Ascend4nt Posted October 23, 2010 Share Posted October 23, 2010 (edited) kiboot, if you just want to check the *total* combined CPU usage once using my Performance Counters UDF, below would be the easiest way.. Oh, and you shouldn't really get an error here (unless it has to do with the short sleep time), but anyway the code below takes the possibility of an error into account: #include "_PDH_PerformanceCounters.au3" _PDH_Init() Local $hPDHQuery,$hCPUCounter,$iCPUUsage $hPDHQuery=_PDH_GetNewQueryHandle() $hCPUCounter=_PDH_AddCounter($hPDHQuery,":238\6\(_Total)") _PDH_CollectQueryData($hPDHQuery) ; collect the query information once (1st collection may fail, so we'll discard it) Sleep(50) While 1 $iCPUUsage=_PDH_UpdateCounter($hPDHQuery,$hCPUCounter) ; collect query info and then grab counter value If Not @error Then ExitLoop Sleep(50) WEnd _PDH_UnInit($hPDHQuery) ConsoleWrite("CPU Counter = "&$iCPUUsage&@CRLF) If the size bothers you, you can actually strip the 7 functions (6 above +1 for string translation) from the UDF. Or just use a strip command for Obfuscator when compiling the code. For me the above gives very accurate results. You can certainly try your luck with the other code however. *edit: (don't bother with the WMI version above if you want something that works quick. Besides, the data it is pulling info from is the same place the Performance Counters pulls info from, only WMI is much slower) Edited October 23, 2010 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Ascend4nt Posted October 23, 2010 Share Posted October 23, 2010 Don't riiight me please. I thought we passed that level of interaction.When was that book published? When Microsoft released first 64bit system? Find "64bit systems", or even better -windows 7- chapter in that book and read about definitions of that structure(s).If the structures are still giving the same data, and only the type sizes have changed, why would you question it. I've worked fairly extensively with 'undocumented' functions on systems from Win 2000->Win 7 x64. Microsoft doesn't document the structures properly on MSDN and creates what you may interpret as 'unions', but really they are just hiding what is already defined by other sources. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
KaFu Posted October 23, 2010 Share Posted October 23, 2010 (edited) Windows NT/2000 Native API Reference. Wasn't aware of this book, that one goes straight to my knowledge repository, thanks m8 ...Here's an online version found via google: Windows NT/2000 Native API ReferenceEdit:Look what I found : Undocumented Windows 2000 Secrets Edited October 23, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Ascend4nt Posted October 23, 2010 Share Posted October 23, 2010 Nice finds. Downloading from the 2nd link as I type! My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
kiboost Posted October 23, 2010 Author Share Posted October 23, 2010 kiboot, if you just want to check the *total* combined CPU usage once using my Performance Counters UDF, below would be the easiest way.. #include "_PDH_PerformanceCounters.au3" _PDH_Init() Local $hPDHQuery,$hCPUCounter,$iCPUUsage $hPDHQuery=_PDH_GetNewQueryHandle() $hCPUCounter=_PDH_AddCounter($hPDHQuery,":238\6\(_Total)") _PDH_CollectQueryData($hPDHQuery) ; collect the query information once (1st collection may fail, so we'll discard it) Sleep(50) While 1 $iCPUUsage=_PDH_UpdateCounter($hPDHQuery,$hCPUCounter) ; collect query info and then grab counter value If Not @error Then ExitLoop Sleep(50) WEnd _PDH_UnInit($hPDHQuery) ConsoleWrite("CPU Counter = "&$iCPUUsage&@CRLF) Many thanks Ascend4nt, works like a charm !! Will adapt this one in my script. It's surprising how many functions and line code it take to just check a value, but I guess we should thanks microsoft here for that ! Thanks, Kib Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79 Link to comment Share on other sites More sharing options...
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