
oo0oo
Active Members-
Posts
23 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
oo0oo's Achievements

Seeker (1/7)
0
Reputation
-
oo0oo reacted to a file: Beats Player
-
oo0oo reacted to a post in a topic: zLib (Deflate/Inflate/GZIP) UDF
-
Change variable in existing object (shockwave flash)
oo0oo replied to VixinG's topic in AutoIt General Help and Support
link is dead... -
Mp3SearchEngine v2.0.1.1 Update of 25 dec 2015
oo0oo replied to wakillon's topic in AutoIt Example Scripts
wakillonerror report: when i search adele / someone like you, there is always an error message. pls test... -
$NewTitle = "My New Title" $OldTitle = WinGetTitle("[active]") WinSetTitle($OldTitle,"",$NewTitle) Like This?
-
killgore i also have same problem... Func _ConsoleInput($sPrompt) Local $Timer = TimerInit() ;Wait time If Not @Compiled Then Return SetError(1, 0, 0) ; Not compiled ConsoleWrite($sPrompt) Local $tBuffer = DllStructCreate("char"), $nRead, $sRet = "" Local $hFile = _WinAPI_CreateFile("CON", 2, 2) While 1 If TimerDiff($Timer)/1000 > 3 Then Msgbox(0,TimerDiff($Timer)/1000,"") _WinAPI_CloseHandle($hFile) Return "y" ExitLoop EndIf _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), 1, $nRead) If DllStructGetData($tBuffer, 1) = @CR Then ExitLoop If $nRead > 0 Then $sRet &= DllStructGetData($tBuffer, 1) Sleep(25) WEnd _WinAPI_CloseHandle($hFile) Return $sRet EndFunc
-
@ trancexx :hardly nothing impossible! i don't understand...can u help us?
-
I also hv this problem... everybody... who can help me?
-
sound:awesome! 5 star from me!
-
autoit how to determine the program has stopped(Finished).
oo0oo replied to oo0oo's topic in AutoIt General Help and Support
Process to determine whether the error: If the file does not exist,prompt or appear input box. know to finish loading image file(also used CPU usage),(send CTRL+A), labeling target Drive is "New_GHO" then open target dialog box(send CTRL+E)& (send "New_GHO") (Send ENTER) If CPU usage in three minutes still zero, and finally to determine the program has been extracted all files from ghost explorer. Close Ghost Explorer... Erase "New_GHO" to no name(label) Exit and Restart Computer...or continue to another job (add SRS Driver/registry:add runone silent latest software..) Hope to do unattended... -
I mean when norton ghost explorer extract files is completed(at that time be more than 2% CPU usage) when caught Process/CPU usage is 0% (three minutes to wait, still 0%) and then automatically execute another program (such as restart the computer...) see title... Is there a way to monitor CPU/Ram usage of the process?... The following code is just the beginning of the concept and reference In WINPE enviroment, I just put the old data revenue a folder, and then start with ghost explorer to extract all the files, then restart the computer (not MS Shutdown.exe) Stated: Image file has a Sysprep. (Such as unattended feature) The following code is just the beginning of the concept and reference... #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Opt("TrayIconHide", 1) HotKeySet("{ESC}", "_Exit") Global $iMemo, $hDebugGUI,$Count=0 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,$Msg,$GUI_EVENT_CLOSE Global $iMemo, $hDebugGUI,$Count=0 Global $MenuItem1,$MenuItem2,$MenuItem3,$MenuItem4,$TCB1,$TCB2,$PInput1,$PInput2,$PButton1,$PButton2,$Ppwd1,$Ppwd2,$DrvCB1,$DrvCB2,$Go,$GhoRadio1,$GhoRadio2,$GhoInput,$GhostBtn,$GhoFavoriteCB,$FavoComBo,$OtherFavoBtn ;$prg = "cmd.exe" $prg = "Z:\GHOST\GHOSTEXP11.EXE Z:\GHOST\BACKUP.GHO" Run($prg) Sleep(1000) Send("goXP");here is password Sleep(500) Send("{ENTER}") Sleep(2500) DriveSetLabel("D:\", "New_Label") Send("{ENTER 2}") sleep(500) Send("{DOWN 2}") sleep(3000) Send("{CTRLDOWN}a{CTRLUP}") sleep(200) Send("{CTRLDOWN}e{CTRLUP}") Send("New_Label") sleep(2000) Send("{ALTDOWN}c{ALTUP}") sleep(3000) Send("{ALTDOWN}c{ALTUP}") Send("{ENTER}") ;............................................................................. ;Here is the wait for the extraction is complete ;............................................................................. DriveSetLabel("D:\", "") Local $var = "Test" ConsoleWrite("var=" & $var & @CRLF) ; Running this in a text editor which can trap console output should produce "var=Test" ;$PID = ProcessExists($prg) $PID = ProcessExists("GHOSTE~1.EXE") If $PID = 0 Then ConsoleWrite(@CRLF & "ERROR! Process " & $prg & " not found! Aborting..." & @CRLF) Exit EndIf #Region ### START Koda GUI section ### Form=d:\autoGhoExp.kxf $GUI = GUICreate("AutoGhost Explorer", 447, 177, 371, 560) $MenuItem1 = GUICtrlCreateMenu("&Session") $MenuItem2 = GUICtrlCreateMenuItem("S&ave", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("&Load", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("E&xit", $MenuItem1) $TCB1 = GUICtrlCreateCheckbox("&1.", 5, 3, 30, 17) $TCB2 = GUICtrlCreateCheckbox("&2.", 5, 32, 30, 17) $PInput1 = GUICtrlCreateInput("", 32, 1, 249, 21) $PInput2 = GUICtrlCreateInput("", 32, 30, 249, 21) $PButton1 = GUICtrlCreateButton("Browse", 285, 1, 46, 24, $WS_GROUP) $PButton2 = GUICtrlCreateButton("Browse", 285, 28, 46, 24, $WS_GROUP) $Ppwd1 = GUICtrlCreateInput("", 332, 1, 73, 21) GUICtrlSetLimit(-1, 10) GUICtrlSetTip(-1, "Your Password Here!") $Ppwd2 = GUICtrlCreateInput("", 332, 29, 73, 21) GUICtrlSetLimit(-1, 10) GUICtrlSetTip(-1, "Your Password Here!") $DrvCB1 = GUICtrlCreateCombo("C", 406, 0, 34, 25) GUICtrlSetData(-1, "C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") $DrvCB2 = GUICtrlCreateCombo("D", 406, 29, 34, 25) GUICtrlSetData(-1, "C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") $Go = GUICtrlCreateButton("Go&GhoGo", 5, 56, 436, 33, $WS_GROUP) $GhoInput = GUICtrlCreateInput("", 21, 111, 241, 21) $GhoRadio2 = GUICtrlCreateRadio("", 5, 111, 17, 15) $GhostBtn = GUICtrlCreateButton("B&rowse", 263, 111, 46, 24, $WS_GROUP) $GhoFavoriteCB = GUICtrlCreateCheckbox("Favorites:", 321, 93, 72, 16) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetTip(-1, "Favorites Setting for GV*OS (ini file)") $FavoComBo = GUICtrlCreateCombo("", 311, 111, 129, 25) $OtherFavoBtn = GUICtrlCreateButton("ü", 399, 91, 41, 16, $WS_GROUP) GUICtrlSetTip(-1, "Use other favorite ini file...") $iMemo = GUICtrlCreateEdit("", 1, 137, 468,20) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUICtrlSetBkColor($iMemo, 0xFFFFFF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $ProcHandle = DllCall("kernel32.dll", "hwnd", "OpenProcess", "dword", $Process_All_Access, "int", False, "dword", $PID) $ProcHandle = $ProcHandle[0] 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 & "PID:" & $PID & " | CPU usage:" & $Process_CPU_Usage & "% | Mem usage:" & $mem & "KB | Time:" & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & @CR MemoWrite($info) Sleep(1000) ProcessCPUUsage () If Not ProcessExists($PID) Then _Exit() WEnd Func ProcessCPUUsage () Sleep(1000) If $Process_CPU_Usage=0 Then Sleep(1000) If $Process_CPU_Usage=0 Then $Count=$Count+1 If $Count=60 Then Msgbox(0,"Timeout","Timeout",5) EndIf EndFunc 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
-
autoit how to determine the program has stopped(Finished).
oo0oo replied to oo0oo's topic in AutoIt General Help and Support
Hi! Thank! somdcomputerguy I mean when norton ghost explorer extract files is completed(at that time must be more than 1% CPU usage) when caught Process/CPU usage is 0% (three minutes to wait, still 0%) and then automatically execute another program (such as restart the computer...) I finded some idea from forum: #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Opt("TrayIconHide", 1) HotKeySet("{ESC}", "_Exit") Global $iMemo, $hDebugGUI,$Count=0 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,$Msg,$GUI_EVENT_CLOSE Global $iMemo, $hDebugGUI,$Count=0 Global $MenuItem1,$MenuItem2,$MenuItem3,$MenuItem4,$TCB1,$TCB2,$PInput1,$PInput2,$PButton1,$PButton2,$Ppwd1,$Ppwd2,$DrvCB1,$DrvCB2,$Go,$GhoRadio1,$GhoRadio2,$GhoInput,$GhostBtn,$GhoFavoriteCB,$FavoComBo,$OtherFavoBtn ;$prg = "cmd.exe" $prg = "Z:\GHOST\GHOSTEXP11.EXE Z:\GHOST\BACKUP.GHO" Run($prg) Sleep(1000) Send("goXP");here is password Sleep(500) Send("{ENTER}") Sleep(2500) DriveSetLabel("D:\", "New_Label") Send("{ENTER 2}") sleep(500) Send("{DOWN 2}") sleep(3000) Send("{CTRLDOWN}a{CTRLUP}") sleep(200) Send("{CTRLDOWN}e{CTRLUP}") Send("New_Label") sleep(2000) Send("{ALTDOWN}c{ALTUP}") sleep(3000) Send("{ALTDOWN}c{ALTUP}") Send("{ENTER}") ;............................................................................. ;Here is the wait for the extraction is complete ;............................................................................. DriveSetLabel("D:\", "") Local $var = "Test" ConsoleWrite("var=" & $var & @CRLF) ; Running this in a text editor which can trap console output should produce "var=Test" ;$PID = ProcessExists($prg) $PID = ProcessExists("GHOSTE~1.EXE") If $PID = 0 Then ConsoleWrite(@CRLF & "ERROR! Process " & $prg & " not found! Aborting..." & @CRLF) Exit EndIf #Region ### START Koda GUI section ### Form=d:\autoGhoExp.kxf $GUI = GUICreate("AutoGhost Explorer", 447, 177, 371, 560) $MenuItem1 = GUICtrlCreateMenu("&Session") $MenuItem2 = GUICtrlCreateMenuItem("S&ave", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("&Load", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("E&xit", $MenuItem1) $TCB1 = GUICtrlCreateCheckbox("&1.", 5, 3, 30, 17) $TCB2 = GUICtrlCreateCheckbox("&2.", 5, 32, 30, 17) $PInput1 = GUICtrlCreateInput("", 32, 1, 249, 21) $PInput2 = GUICtrlCreateInput("", 32, 30, 249, 21) $PButton1 = GUICtrlCreateButton("Browse", 285, 1, 46, 24, $WS_GROUP) $PButton2 = GUICtrlCreateButton("Browse", 285, 28, 46, 24, $WS_GROUP) $Ppwd1 = GUICtrlCreateInput("", 332, 1, 73, 21) GUICtrlSetLimit(-1, 10) GUICtrlSetTip(-1, "Your Password Here!") $Ppwd2 = GUICtrlCreateInput("", 332, 29, 73, 21) GUICtrlSetLimit(-1, 10) GUICtrlSetTip(-1, "Your Password Here!") $DrvCB1 = GUICtrlCreateCombo("C", 406, 0, 34, 25) GUICtrlSetData(-1, "C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") $DrvCB2 = GUICtrlCreateCombo("D", 406, 29, 34, 25) GUICtrlSetData(-1, "C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") $Go = GUICtrlCreateButton("Go&GhoGo", 5, 56, 436, 33, $WS_GROUP) $GhoInput = GUICtrlCreateInput("", 21, 111, 241, 21) $GhoRadio2 = GUICtrlCreateRadio("", 5, 111, 17, 15) $GhostBtn = GUICtrlCreateButton("B&rowse", 263, 111, 46, 24, $WS_GROUP) $GhoFavoriteCB = GUICtrlCreateCheckbox("Favorites:", 321, 93, 72, 16) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetTip(-1, "Favorites Setting for GV*OS (ini file)") $FavoComBo = GUICtrlCreateCombo("", 311, 111, 129, 25) $OtherFavoBtn = GUICtrlCreateButton("ü", 399, 91, 41, 16, $WS_GROUP) GUICtrlSetTip(-1, "Use other favorite ini file...") $iMemo = GUICtrlCreateEdit("", 1, 137, 468,20) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUICtrlSetBkColor($iMemo, 0xFFFFFF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $ProcHandle = DllCall("kernel32.dll", "hwnd", "OpenProcess", "dword", $Process_All_Access, "int", False, "dword", $PID) $ProcHandle = $ProcHandle[0] 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 & "PID:" & $PID & " | CPU usage:" & $Process_CPU_Usage & "% | Mem usage:" & $mem & "KB | Time:" & $hour & ":" & $minutes & ":" & $seconds & "." & $milliseconds & @CR MemoWrite($info) Sleep(1000) ProcessCPUUsage () If Not ProcessExists($PID) Then _Exit() WEnd Func ProcessCPUUsage () Sleep(1000) If $Process_CPU_Usage=0 Then Sleep(1000) If $Process_CPU_Usage=0 Then $Count=$Count+1 If $Count=60 Then Msgbox(0,"Timeout","Timeout",5) EndIf EndFunc 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 Thank All!!! -
I use norton ghost explorer to extract files from Image, autoit how to determine the procedures have been completed, and then do another task or(restart/shutdown). I mean when norton ghost explorer extract files is completed(at that time must be more than 1% CPU usage) when caught Process/CPU usage is 0% (three minutes to wait, still 0%) and then automatically execute another program (such as restart the computer...) Because the ghost explorer will not retreat (After extraction,Still waiting for closure) if............then ;if CPU Usage (In 3 minutes still 0%) then... Run('TASKKILL /F /PID ' & ProcessExists('ghost explorer11.exe')) shutdown(9) endif is there a way to monitor CPU/Ram usage of the process? see #5 post
-
Great Jobs! Thank!