Sign in to follow this  
Followers 0
Entropy

CPU-Z through WinAPI. Dreams?

7 posts in this topic

Hi, there!

I have a fairy idea for my app: get a current CPU frequency.

The only way i found is take info from WMI (Win32_Processor) object. But trouble is CurrentClockSpeed and MaxClockSpeed is the same.

I don't know what is a problem, but seems this object does not collect info in Speed Step or Cool'n'Queit frequency decreasing issue.

It is possible to measure current frequency, through RDMSR, but it doesn't works. It returns the base frequency.

Any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Using CPUZ's ability to take in a parameter to generate a report file, I created this script for you:

#include <file.au3>
Run("cpuz.exe -txt=" & @TempDir & "Report")
$linecount = _FileCountLines(@TempDir & "Report.txt")

For $i = 1 To $linecount Step 1
    $line = FileReadLine(@TempDir & "Report.txt", $i)
    If StringInStr($line, "Core Speed") Then
        $correctLine = $line
        ExitLoop
    EndIf
Next

FileDelete(@TempDir & "Report.txt")

$formattedLine = StringStripWS($correctLine, 8)
$finalString = StringTrimLeft($formattedLine, 9)

MsgBox(0, "", "Your Core Speed is: " & $finalString)
Edited by sleepydvdr

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

Using CPUZ's ability to take in a parameter to generate a report file, I created this script for you:

#include <file.au3>
Run("cpuz.exe -txt=" & @TempDir & "Report")
$linecount = _FileCountLines(@TempDir & "Report.txt")

For $i = 1 To $linecount Step 1
    $line = FileReadLine(@TempDir & "Report.txt", $i)
    If StringInStr($line, "Core Speed") Then
        $correctLine = $line
        ExitLoop
    EndIf
Next

FileDelete(@TempDir & "Report.txt")

$formattedLine = StringStripWS($correctLine, 8)
$finalString = StringTrimLeft($formattedLine, 9)

MsgBox(0, "", "Your Core Speed is: " & $finalString)

Brilliant idea! Thanks!

The only thing, i worry about using this script is to trace cpu frequency in "real time".

What do you think?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I didn't realize you wanted to monitor it in real time. In that case, my suggestion would not be efficient. I did some reading on the subject. The post by Mark below has some good info:

http://forums.extremeoverclocking.com/t348585.html

I don't think I will be able to help you any more. It is out of my league. Good luck.

Edited by sleepydvdr

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Can you try this:

;coded by UEZ build 2011-12-08
Global $exit = False
Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

$hGUI = GUICreate("WMI CPU / Memory Monitor", 385, 140, -1, -1)
GUISetFont(8, 400, 0, "Arial")
$idLabel_CPU = GUICtrlCreateLabel("CPU", 58, 12, 24, 18)
$idLabel_Current = GUICtrlCreateLabel("Current Speed", 11, 36, 77, 18)
$idLabel_Max = GUICtrlCreateLabel("Max Speed", 25, 60, 58, 18)
$idLabel_CPULoad = GUICtrlCreateLabel("CPU Load", 31, 84, 78, 18)
$idLabel_MemAvailable = GUICtrlCreateLabel("Available Mem", 7, 110, 78, 18)

$idInput_CPU = GUICtrlCreateInput("", 88, 8, 285, 22)
$idInput_Current = GUICtrlCreateInput("0", 88, 32, 285, 22)
$idInput_Max = GUICtrlCreateInput("0", 88, 56, 285, 22)
$idInput_CPULoad = GUICtrlCreateInput("0", 88, 80, 285, 22)
$idInput_MemAvailable = GUICtrlCreateInput("0", 88, 106, 285, 22)
GUISetState(@SW_SHOW)

WMI_GetCPUMemInfo()
Exit

Func WMI_GetCPUMemInfo($host = "localhost") ;coded by UEZ 2011
    Local $colItems
    Local $objWMIService = ObjGet("winmgmts:.rootcimv2")
    Local $objRefresher = ObjCreate("WbemScripting.SWbemRefresher")
    Local $colItems = $objRefresher.AddEnum($objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").ObjectSet
    Local $colItems2 = $objRefresher.AddEnum($objWMIService, "Win32_Processor").ObjectSet
    $objRefresher.Refresh
    For $objItem In $colItems2
        GUICtrlSetData($idInput_CPU, StringStripWS($objItem.Name, 7))
        GUICtrlSetData($idInput_Current, $objItem.CurrentClockSpeed & " MHz")
        GUICtrlSetData($idInput_Max, $objItem.MaxClockSpeed & " MHz")
        GUICtrlSetData($idInput_CPULoad, $objItem.LoadPercentage & "%")
    Next
    For $objItem In $colItems
        GUICtrlSetData($idInput_MemAvailable, $objItem.AvailableBytes & " Bytes / " & Round($objItem.AvailableBytes / 1024^2, 2) & " MB")
    Next
    Do
        $objRefresher.Refresh
        For $objItem In $colItems2
            GUICtrlSetData($idInput_Current, $objItem.CurrentClockSpeed & " MHz")
            GUICtrlSetData($idInput_CPULoad, $objItem.LoadPercentage & "%")
        Next
        For $objItem In $colItems
            GUICtrlSetData($idInput_MemAvailable, $objItem.AvailableBytes & " Bytes / " & Round($objItem.AvailableBytes / 1024^2, 2) & " MB")
        Next
    Until GUIGetMsg() = -3
EndFunc

Func ObjErrorHandler()
    ConsoleWrite(   "A COM Error has occured!" & @CRLF  & @CRLF & _
                                "err.description is: "    & @TAB & $oErrorHandler.description    & @CRLF & _
                                "err.windescription:"     & @TAB & $oErrorHandler & @CRLF & _
                                "err.number is: "         & @TAB & Hex($oErrorHandler.number, 8)  & @CRLF & _
                                "err.lastdllerror is: "   & @TAB & $oErrorHandler.lastdllerror   & @CRLF & _
                                "err.scriptline is: "     & @TAB & $oErrorHandler.scriptline     & @CRLF & _
                                "err.source is: "         & @TAB & $oErrorHandler.source         & @CRLF & _
                                "err.helpfile is: "       & @TAB & $oErrorHandler.helpfile       & @CRLF & _
                                "err.helpcontext is: "    & @TAB & $oErrorHandler.helpcontext & @CRLF _
                            )
EndFunc

Br,

UEZ

Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Hi, there!

I have a fairy idea for my app

Any ideas?

That tittle. CPU-Z through WinAPI. Dreams?

>I have a fairy idea

>a fairy idea

>fairy

Are you sure it wasn't a fairy dream?


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Thanks, UEZ!

Very nice script, but, as i said CurrentCPUFrequency and MaxCPUFrequency, that retrived from WIN32_Processor returns the same value

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