PoopDeck Posted December 27, 2007 Share Posted December 27, 2007 I'm new to autoit a bit. Ive done a few projects before but im a little confused at the momentI'm trying to get the CPU Usage of the computer and there doesn't seem to be anything on itI did find ProcessListProperties.au3 and i put that into the code I'm using.$list = ProcessList() for $i = 1 to $list[0][0] $avProcs = _ProcessListProperties($list[$i][0]) if $avprocs[1][6] = 0 Then $d += 1 else $B += $avProcs[1][6] $C += 1 endif next $CpuUsage = ($b / $c)I tried that but it is inefficient.What i was thinking was _Processlistproperties($cpu)http://www.autoitscript.com/forum/index.ph...mp;#entry409276I dont know what the CPU would be. Link to comment Share on other sites More sharing options...
weaponx Posted December 27, 2007 Share Posted December 27, 2007 (edited) This is normal, unless you are running something taxing when you run PsaltyDS' script like a game or PRIME95. Run your script while a benchmark is in progress, it will ramp up. Edited December 27, 2007 by weaponx Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 27, 2007 Share Posted December 27, 2007 (edited) Try this: Global $wbemFlagReturnImmediately = 0x10 Global $wbemFlagForwardOnly = 0x20 Global $wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly Global $strComputer = @ComputerName Global $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Global $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlags) $n = 0 $sMsg = "" For $objItem In $colItems $sMsg &= $n & ": LoadPercentage: " & $objItem.LoadPercentage & @CRLF $n += 1 Next MsgBox(64, "CPU Load", $sMsg) P.S. For comparison: On a 3GHz P4 HT CPU, it shows as two processors at 0% each when idle, show about 15-20% on one and about 50-60% on the other during an AV scan. Edited December 27, 2007 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
PoopDeck Posted December 28, 2007 Author Share Posted December 28, 2007 thank you psaltyds, that helps alot. Something i dont understand would be that this program uses WMI (which i dont understand atm but will learn hopefully) and the process wmiprvse.exe is for the WMI. Is there another way to get the CPU usage without using another program to get it for you? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 28, 2007 Share Posted December 28, 2007 thank you psaltyds, that helps alot. Something i dont understand would be that this program uses WMI (which i dont understand atm but will learn hopefully)and the process wmiprvse.exe is for the WMI. Is there another way to get the CPU usage without using another program to get it for you?I'm not sure what you mean by "another program". The WMI is what ships with Windows for this specific purpose. I guess you could switch to C++ and get the proper libraries to code it as a standalone executable, but what's the problem with using WMI? 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 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