Jump to content

Basic Cpu Info Script


tip
 Share

Recommended Posts

I spend sometime to find a script which gives CPU Name, Clock Speed and Number of Cores but I couldn't find anything.

So I've learned how it can be done.

Although it is a very simple script I'm posting it, hoping people to find it easier then I did :P ...

Plus I'm using 2 different ways to obtain information. Second one can be useful when you don't want to wait 3-10 seconds.

_CpuInfo function uses WMI objects and takes some time to return the wanted information. (This takes 4 seconds on my PC)

_FasterCpuInfo uses Reg Entries(This one takes 0 milliseconds :()

_MemInfo Returns Total Physical Memory.

Func _CpuInfo()
        $wbemFlagReturnImmediately = 0x10
        $wbemFlagForwardOnly = 0x20
        $colItems = ""
        $strComputer = "localhost"

        $Cpu_Output=""
        $Cpu_Core = 0
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                                  $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

        If IsObj($colItems) then
           For $objItem In $colItems
              $Cpu_Output = $Cpu_Output & "Architecture: " & $objItem.Architecture & @CRLF
              $Cpu_Output = $Cpu_Output & "Max Clock Speed: " & $objItem.MaxClockSpeed & @CRLF
              $Cpu_Output = $Cpu_Output & "Name: " & $objItem.Name & @CRLF
              $Cpu_Name = $objItem.Name
              $Cpu_Clock = $objItem.MaxClockSpeed
              $Cpu_Arch = $objItem.Architecture
              $Cpu_Core += 1
          Next
          Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Processor" )
Endif
EndFunc
      
      
Func _FasterCpuInfo()
    $Cpu_Core = 0

For $i= 1 to 1000
    $Temp = RegEnumKey("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\", $i)
    If @error <> 0 then ExitLoop
    $Cpu_Core += 1
Next
    $Cpu_Name = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString")
    $Cpu_Clock = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz")
EndFunc


Func _MemInfo()
    
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Mem_Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalMemoryConfiguration", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Mem_Output = $objItem.TotalPhysicalMemory 
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_LogicalMemoryConfiguration" )
Endif
Return Int($Mem_Output/1024)
EndFunc



Func _Timer_Compare()
$Timer = TimerInit()
_CpuInfo()
$CpuInfo_Timer = "_CpuInfo takes  " & Int(TimerDiff($Timer)) & "  milliseconds"
$timer = 0
$Timer = TimerInit()
_FasterCpuInfo()
$FasterCpuInfo_Timer = "_FasterCpuInfo takes  " & Int(TimerDiff($Timer)) & "  milliseconds"
$timer = 0
$Timer = TimerInit()
_MemInfo()
$MemInfo_Timer = "_MemInfo takes  " & Int(TimerDiff($Timer)) & "  milliseconds"
MsgBox(64,"Timers",$CpuInfo_Timer & @CRLF & @CRLF & $FasterCpuInfo_Timer & @CRLF & @CRLF & $MemInfo_Timer)
EndFunc

Timer_Compare()

I'm not sure whether _FasterCPUInfo function is a valid way for everyone or just working on my PC.

So I will be glad if you give me some feedback or share your knowledge about it...

Enjoy

Sincerely

Tip

P.S.: There is a good chance that similar script exists already on the forum... If it is so, know that I don't mean to be rude I just couldn't find it...

Edited by tip

[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Link to comment
Share on other sites

Hi Tip..

you did well but :

Fastest way to get the number of cores -> EnvGet("NUMBER_OF_PROCESSORS")

Example

Msgbox(0, "Number Of Cores", EnvGet("NUMBER_OF_PROCESSORS"))

Some computerinfo scripts

http://www.autoitscript.com/forum/index.ph...amp;hl=CompInfo

http://www.autoitscript.com/forum/index.ph...amp;hl=CompInfo

and

Try -> MemGetStats ( )

Returns a seven-element array containing the memory information:

$array[0] = Memory Load (Percentage of memory in use)

$array[1] = Total physical RAM

$array[2] = Available physical RAM

$array[3] = Total Pagefile

$array[4] = Available Pagefile

$array[5] = Total virtual

$array[6] = Available virtual

All memory sizes are in kilobytes.

Best regards,

Emiel

Best regards,Emiel Wieldraaijer

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...