Jump to content

Check CPU usage of a process


 Share

Recommended Posts

  • Moderators

gertsolo,

First hit when I searched just now - need to sharpen up those searching skills! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

gertsolo,

First hit when I searched just now - need to sharpen up those searching skills! :D

M23

Already tested that. For some reason it always gives zero for CPU usage, yet in the task manager it shows usage?

The more you learn, the less you know.

Link to comment
Share on other sites

  • Moderators

gertsolo,

Works for me. As this only takes a snapshot of the CPU usage, are you sure your app is actually doing anything as the script runs?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yup,

tested it several times, it always gives 0 when task manager says alternating 02 en 01.

Never mind, I made a loop of several checks an added them up.

Works fine now,

cheers!

Edited by gertsolo

The more you learn, the less you know.

Link to comment
Share on other sites

Try this:

#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)
Opt("TrayIconHide", 1)
HotKeySet("{ESC}", "_Exit")

Global Const $Process_All_Access = 0x1F0FFF
Global $CreateTime = DllStructCreate("dword;dword")
Global $ExitTime = DllStructCreate("dword;dword")
Global $KernelTime = DllStructCreate("dword;dword")
Global $UserTime = DllStructCreate("dword;dword")
Global $FileTime = DllStructCreate("dword;dword")
Global $SystemTime = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
Global $IdleTime = DllStructCreate("dword;dword")
Global $sUserTime, $sKernelTime, $eUserTime, $eKernelTime
Global $ret, $hour, $minutes, $seconds, $milliseconds
Global $ProcHandle, $Process_CPU_Usage
Global $PID, $CPUTime, $mem, $prg
Global $logical_cpus = CPU()
Global $hProc
Global $GUI, $info


$prg = "calc.exe"

Run($prg)
Sleep(500)

$PID = ProcessExists($prg)
If $PID = 0 Then
    ConsoleWrite(@CRLF & "ERROR! Process " & $prg & " not found! Aborting..." & @CRLF)
    Exit
EndIf

Global $iMemo, $hDebugGUI
$GUI = GUICreate("Process Information v0.35 Beta by UEZ - Press ESC to quit! Just do some calculations...", 740, 25, -1, -1, BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$iMemo = GUICtrlCreateEdit("", -1, -1, 820)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($iMemo, 0xFFFFFF)
GUISetState()

$ProcHandle = DllCall("kernel32.dll", "hwnd", "OpenProcess", "dword", $Process_All_Access, "int", False, "dword", $PID)
$ProcHandle = $ProcHandle[0]

;~ ConsoleWrite(@CRLF & @CRLF & "Process Information v0.30 Beta by UEZ" & @CRLF)
;~ ConsoleWrite("=====================================" & @CRLF & @CRLF)
;~ ConsoleWrite("(Press ESC to exit)" & @CRLF)

While 1
    $CPUTime = _GetProcTime($ProcHandle)
    $mem = _ProcessGetMem($ProcHandle) / 1024
    $hour = Int($CPUTime / 10000000 / 3600)

    $minutes = Int($CPUTime / 10000000 / 60)
    If $minutes < 10 Then $minutes = "0" & $minutes

    $seconds = Round((Int($CPUTime / 10000000) / 60 - Int($CPUTime / 10000000 / 60)) * 60, 0)
    If $seconds < 10 Then $seconds = "0" & $seconds

    $milliseconds = Round((Int($CPUTime / 10000) / 1000 - Int(Int($CPUTime / 10000) / 1000)) * 1000, 0)
    If $milliseconds < 10 Then $milliseconds = "00" & $milliseconds
    If $milliseconds > 9 And $milliseconds < 100 Then $milliseconds = "0" & $milliseconds

    $info = @CR & $prg & " | PID: " & $PID & " | CPU time: " & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & " (h:m:s.ms) | Mem usage: " & $mem & " KB | CPU usage: " & $Process_CPU_Usage & " % " & @CR
    MemoWrite($info)

;~ ConsoleWrite($prg & " | PID: " & $PID & " | CPU time: " & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & " (h:m:s.ms) | Mem usage: " & $mem & " KB | CPU usage: " & $Process_CPU_Usage & " % " & @CR)
    Sleep(1000)
    If Not ProcessExists($PID) Then _Exit()
WEnd


Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage)
EndFunc ;==>MemoWrite

Func _GetProcTime($ProcessHandle)
    $ret = DllCall("kernel32.dll", "int", "GetProcessTimes", "int", $ProcessHandle, "ptr", DllStructGetPtr($CreateTime), "ptr", DllStructGetPtr($ExitTime), "ptr", DllStructGetPtr($KernelTime), "ptr", DllStructGetPtr($UserTime))
    If $ret[0] = 0 Then
    ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessTimes call" & @CRLF)
    SetError(1, 0, $ret[0])
    EndIf
    $sKernelTime = DllStructGetData($KernelTime, 1)
    $sUserTime = DllStructGetData($UserTime, 1)
    $Process_CPU_Usage = Floor(($sKernelTime - $eKernelTime + $sUserTime - $eUserTime) / 100000 / $logical_cpus)
    If $Process_CPU_Usage > 100 Then $Process_CPU_Usage = "100"
    $eKernelTime = $sKernelTime
    $eUserTime = $sUserTime
    Return $sUserTime + $sKernelTime
EndFunc ;==>_GetProcTime

Func _ProcessGetMem($ProcessHandle) ;get physical memory of the process -> http://msdn.microsoft.com/en-us/library/ms683219%28VS.85%29.aspx
    Local $structPROCESS_MEMORY_COUNTERS, $structPROCESS_MEMORY_COUNTERS_EX, $nSize, $aRet
    If @OSVersion <> "WIN_7" Then
    $structPROCESS_MEMORY_COUNTERS = DllStructCreate("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") ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx
    $nSize = DllStructGetSize($structPROCESS_MEMORY_COUNTERS)
    $aRet = DllCall("psapi.dll", "int", "GetProcessMemoryInfo", "hwnd", $ProcessHandle, "ptr", DllStructGetPtr($structPROCESS_MEMORY_COUNTERS), "dword", $nSize) ;call GetProcessMemoryInfo
    If $aRet[0] = 0 Then
    ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessMemoryInfo call" & @LF)
    SetError(1, 0, $aRet[0])
    EndIf
    Return DllStructGetData($structPROCESS_MEMORY_COUNTERS, "WorkingSetSize")
    Else
    $structPROCESS_MEMORY_COUNTERS_EX = DllStructCreate("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") ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx
    $nSize = DllStructGetSize($structPROCESS_MEMORY_COUNTERS_EX)
    $aRet = DllCall("Kernel32.dll", "int", "K32GetProcessMemoryInfo", "hwnd", $ProcessHandle, "ptr", DllStructGetPtr($structPROCESS_MEMORY_COUNTERS_EX), "dword", $nSize) ;call GetProcessMemoryInfo
    If $aRet[0] = 0 Then
    ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessMemoryInfo call" & @LF)
    SetError(1, 0, $aRet[0])
    EndIf
;~  ConsoleWrite("WorkingSetSize: " & Round(DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "WorkingSetSize") / 1024, 0) & @CRLF & _
;~  "PrivateUsage: " & Round(DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "PrivateUsage") / 1024, 0) & @CRLF & @CRLF)
    Return DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "PrivateUsage")
    EndIf
EndFunc ;==>_ProcessGetMem

Func CPU() ;get logical CPU(s)
    Local $i, $j, $x, $os, $colItems, $HW_Processor_Description, $HW_Processor_Manufacturer, $HW_Processor_MaxClockSpeed, $HW_Processor_Name, $HW_Processor_SocketDesignation
    Local $system = "Localhost"
    Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $system & "\root\cimv2")

    $colItems = $objWMIService.ExecQuery("SELECT Caption from Win32_OperatingSystem", "WQL", 0x30) ;get OS version
    If IsObj($colItems) Then
    For $objItem In $colItems
    $os = $objItem.Caption
    Next
    EndIf
    If StringInStr($os, "2003") > 0 Or StringInStr($os, "2000") > 0 Or StringInStr(StringUpper($os), "XP") > 0 Then
    $colItems = $objWMIService.ExecQuery("Select Name, Description, Manufacturer, MaxClockSpeed, SocketDesignation from Win32_Processor", "WQL", 0x30)
    Else
    $colItems = $objWMIService.ExecQuery("Select Name, Description, Manufacturer, MaxClockSpeed, SocketDesignation, NumberOfCores, NumberOfLogicalProcessors from Win32_Processor", "WQL", 0x30)
    EndIf
    If IsObj($colItems) Then
    $i = 0
    $j = 0
    $HW_Processor_SocketDesignation = ""
    For $objItem In $colItems ;get amount of logical CPUs
    If StringInStr(StringLower($HW_Processor_SocketDesignation), StringLower($objItem.SocketDesignation)) = 0 Then
    $HW_Processor_SocketDesignation &= $objItem.SocketDesignation & ", "
    EndIf
    $i = $i + 1
    Next
    If StringInStr($os, "2003") > 0 Or StringInStr($os, "2000") > 0 Or StringInStr(StringUpper($os), "XP") > 0 Then
    $x = StringSplit(Remove_Last_Comma($HW_Processor_SocketDesignation), ",")
    $j = UBound($x) - 1
    Else
    $i = $objItem.NumberOfCores
    $j = $objItem.NumberOfLogicalProcessors / $i
    EndIf
    If $j > $i Then $j = $i
    EndIf
    Return ($i)
EndFunc ;==>CPU

Func Remove_Last_Comma($str)
    If StringRight($str, 2) = ", " Then $str = StringMid($str, 1, StringLen($str) - 2)
    Return $str
EndFunc ;==>Remove_Last_Comma

Func _Exit()
    DllCall("kernel32.dll", "int", "CloseHandle", "int", $ProcHandle)
    DllCall("psapi.dll", "int", "CloseHandle", "hwnd", $ProcHandle)
    ProcessClose($pid)
    Exit
EndFunc ;==>_Exit

Just do some calculations...

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

Link to comment
Share on other sites

  • 1 year later...

Try this:

<big snip>

Just do some calculations...

UEZ

Did tried on Windows7 64bit, didn't show any differences when doing heavy calculations.

Could it be a Win7 issue?

Are there other ways to see what has been done on a process?

Thanks in advance,

John

Link to comment
Share on other sites

Try looking at " from my Performance Counters UDF.

Link to comment
Share on other sites

Indeed, the calculator in Win7 is unable to calculate n! with huge numbers:

Try this:

;coded by UEZ
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)
Opt("TrayIconHide", 1)
HotKeySet("{ESC}", "_Exit")

Global Const $Process_All_Access = 0x1F0FFF
Global $CreateTime = DllStructCreate("dword;dword")
Global $ExitTime = DllStructCreate("dword;dword")
Global $KernelTime = DllStructCreate("dword;dword")
Global $UserTime = DllStructCreate("dword;dword")
Global $FileTime = DllStructCreate("dword;dword")
Global $SystemTime = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
Global $IdleTime = DllStructCreate("dword;dword")
Global $sUserTime, $sKernelTime, $eUserTime, $eKernelTime
Global $ret, $hour, $minutes, $seconds, $milliseconds
Global $ProcHandle, $Process_CPU_Usage
Global $PID, $CPUTime, $mem, $prg
Global $logical_cpus = CPU()
Global $hProc
Global $GUI, $info

Global $hFile, $au3, $autoit3
Global $dummy_exe = @ScriptDir & "\" & "Dummy.exe"
Global $dummy_au3 = @ScriptDir & "\" & "Dummy.au3"
If Not FileExists($dummy_exe) Then
    $hFile = FileOpen($dummy_au3, 2)
    $au3 = "While 1" & @CRLF & "WEnd"
    FileWrite($hFile, $au3)
    FileClose($hFile)
    If @OSArch = "x86" Then
        $autoit3 = '"' & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\aut2exe\aut2exe.exe" & '"'
    Else
        $autoit3 = '"' & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt", "InstallDir") & "\aut2exe\aut2exe.exe" & '"'
    EndIf
    RunWait($autoit3 & ' /in "' & $dummy_au3 & '" /out "' & $dummy_exe & '" /nopack /comp 2')
EndIf

$PID = Run($dummy_exe)

If $PID = 0 Then
    ConsoleWrite(@CRLF & "ERROR! Process " & $prg & " not found! Aborting..." & @CRLF)
    Exit
EndIf

Global $iMemo, $hDebugGUI
$GUI = GUICreate("Process Information v0.40 Beta by UEZ - Press ESC to quit! Just do some calculations...", 740, 25, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS))
$iMemo = GUICtrlCreateEdit("", -1, -1, 820)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($iMemo, 0xFFFFFF)
GUISetState()

$ProcHandle = DllCall("kernel32.dll", "hwnd", "OpenProcess", "dword", $Process_All_Access, "int", False, "dword", $PID)
$ProcHandle = $ProcHandle[0]

;~ ConsoleWrite(@CRLF & @CRLF & "Process Information v0.30 Beta by UEZ" & @CRLF)
;~ ConsoleWrite("=====================================" & @CRLF & @CRLF)
;~ ConsoleWrite("(Press ESC to exit)" & @CRLF)

While True
    $CPUTime = _GetProcTime($ProcHandle)
    $mem = _ProcessGetMem($ProcHandle) / 1024
    $hour = Int($CPUTime / 10000000 / 3600)

    $minutes = Int($CPUTime / 10000000 / 60)
    If $minutes < 10 Then $minutes = "0" & $minutes

    $seconds = Round((Int($CPUTime / 10000000) / 60 - Int($CPUTime / 10000000 / 60)) * 60, 0)
    If $seconds < 10 Then $seconds = "0" & $seconds

    $milliseconds = Round((Int($CPUTime / 10000) / 1000 - Int(Int($CPUTime / 10000) / 1000)) * 1000, 0)
    If $milliseconds < 10 Then $milliseconds = "00" & $milliseconds
    If $milliseconds > 9 And $milliseconds < 100 Then $milliseconds = "0" & $milliseconds

    $info = @CR & $prg & " | PID: " & $PID & " | CPU time: " & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & " (h:m:s.ms) | Mem usage: " & $mem & " KB | CPU usage: " & $Process_CPU_Usage & " % " & @CR
    MemoWrite($info)

;~ ConsoleWrite($prg & " | PID: " & $PID & " | CPU time: " & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & " (h:m:s.ms) | Mem usage: " & $mem & " KB | CPU usage: " & $Process_CPU_Usage & " % " & @CR)
    Sleep(1000)
    If Not ProcessExists($PID) Then _Exit()
WEnd


Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage)
EndFunc   ;==>MemoWrite

Func _GetProcTime($ProcessHandle)
    $ret = DllCall("kernel32.dll", "int", "GetProcessTimes", "int", $ProcessHandle, "ptr", DllStructGetPtr($CreateTime), "ptr", DllStructGetPtr($ExitTime), "ptr", DllStructGetPtr($KernelTime), "ptr", DllStructGetPtr($UserTime))
    If $ret[0] = 0 Then
        ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessTimes call" & @CRLF)
        SetError(1, 0, $ret[0])
    EndIf
    $sKernelTime = DllStructGetData($KernelTime, 1)
    $sUserTime = DllStructGetData($UserTime, 1)
    $Process_CPU_Usage = Floor(($sKernelTime - $eKernelTime + $sUserTime - $eUserTime) / 100000 / $logical_cpus)
    If $Process_CPU_Usage > 100 Then $Process_CPU_Usage = "100"
    $eKernelTime = $sKernelTime
    $eUserTime = $sUserTime
    Return $sUserTime + $sKernelTime
EndFunc   ;==>_GetProcTime

Func _ProcessGetMem($ProcessHandle) ;get physical memory of the process -> http://msdn.microsoft.com/en-us/library/ms683219%28VS.85%29.aspx
    Local $structPROCESS_MEMORY_COUNTERS, $structPROCESS_MEMORY_COUNTERS_EX, $nSize, $aRet
    If @OSVersion <> "WIN_7" Then
        $structPROCESS_MEMORY_COUNTERS = DllStructCreate("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") ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx
        $nSize = DllStructGetSize($structPROCESS_MEMORY_COUNTERS)
        $aRet = DllCall("psapi.dll", "int", "GetProcessMemoryInfo", "hwnd", $ProcessHandle, "ptr", DllStructGetPtr($structPROCESS_MEMORY_COUNTERS), "dword", $nSize) ;call GetProcessMemoryInfo
        If $aRet[0] = 0 Then
            ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessMemoryInfo call" & @LF)
            SetError(1, 0, $aRet[0])
        EndIf
        Return DllStructGetData($structPROCESS_MEMORY_COUNTERS, "WorkingSetSize")
    Else
        $structPROCESS_MEMORY_COUNTERS_EX = DllStructCreate("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") ;http://msdn.microsoft.com/en-us/library/ms684877%28VS.85%29.aspx
        $nSize = DllStructGetSize($structPROCESS_MEMORY_COUNTERS_EX)
        $aRet = DllCall("Kernel32.dll", "int", "K32GetProcessMemoryInfo", "hwnd", $ProcessHandle, "ptr", DllStructGetPtr($structPROCESS_MEMORY_COUNTERS_EX), "dword", $nSize) ;call GetProcessMemoryInfo
        If $aRet[0] = 0 Then
            ConsoleWrite("(" & @ScriptLineNumber & ") : = Error in GetProcessMemoryInfo call" & @LF)
            SetError(1, 0, $aRet[0])
        EndIf
;~  ConsoleWrite("WorkingSetSize: " & Round(DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "WorkingSetSize") / 1024, 0) & @CRLF & _
;~  "PrivateUsage: " & Round(DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "PrivateUsage") / 1024, 0) & @CRLF & @CRLF)
        Return DllStructGetData($structPROCESS_MEMORY_COUNTERS_EX, "PrivateUsage")
    EndIf
EndFunc   ;==>_ProcessGetMem

Func CPU() ;get logical CPU(s)
    Local $sLPSystemInfo = DllStructCreate( "ushort dwOemId;" & _
                                                                            "short wProcessorArchitecture;" & _
                                                                            "dword dwPageSize;" & _
                                                                            "ptr lpMinimumApplicationAddress;" & _
                                                                            "ptr lpMaximumApplicationAddress;" & _
                                                                            "long_ptr dwActiveProcessorMask;" & _
                                                                            "dword dwNumberOfProcessors;" & _
                                                                            "dword dwProcessorType;" & _
                                                                            "dword dwAllocationGranularity;" & _
                                                                            "short wProcessorLevel;" & _
                                                                            "short wProcessorRevision")
    Local $aResult = DllCall("Kernel32.dll", "none", "GetSystemInfo", "ptr",DllStructGetPtr($sLPSystemInfo))
    If @error Or Not IsArray($aResult) Then Return SetError(1, 0, 0)
    Return SetError(0, 0, DllStructGetData($sLPSystemInfo, "dwNumberOfProcessors"))
EndFunc   ;==>CPU

Func Remove_Last_Comma($str)
    If StringRight($str, 2) = ", " Then $str = StringMid($str, 1, StringLen($str) - 2)
    Return $str
EndFunc   ;==>Remove_Last_Comma

Func _Exit()
    DllCall("kernel32.dll", "int", "CloseHandle", "int", $ProcHandle)
    DllCall("psapi.dll", "int", "CloseHandle", "hwnd", $ProcHandle)
    ProcessClose($PID)
    Exit
EndFunc   ;==>_Exit

It will create a dummy.exe and start it afterwards.

Dummy exe is just a While 1 Wend AutoIt script.

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

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...