esfalk Posted April 2, 2004 Posted April 2, 2004 Scripters - I am familiar with the MemGetStats function; is there something similiar that returns CPU load, or percent usage (similiar to the Windows Task Manager). I am hoping to pause my script while a program loads large, 3D models before continuing. I don't think that MemGetStats is going to work because after loading the models, they remain in the memory for accessing easily. Thanks, Eric
Valik Posted April 2, 2004 Posted April 2, 2004 You could always read the status bar of the Task Manager with StatusBarGetText...
esfalk Posted April 2, 2004 Author Posted April 2, 2004 Thanks Valik... so you mean, load up Windows Task Manager, go to Performance tab, and read the status bar text? That would work, I suppose, but that seems a bit round-a-bout; is there a more direct reference to CPU Usage?
Developers Jos Posted April 2, 2004 Developers Posted April 2, 2004 (edited) Think this is what he is referencing to: Minimize your taskmanager to the systemtray and then run this script while 1 $rc = StatusBarGetText("Windows Task Manager","",2) msgbox(0,'cpu usage',$rc) wend Edited April 2, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Valik Posted April 2, 2004 Posted April 2, 2004 Think this is what he is referencing to: Minimize your taskmanager to the systemtray and then run this script while 1 $rc = StatusBarGetText("Windows Task Manager","",2) msgbox(0,'cpu usage',$rc) wendWhat he said.
esfalk Posted April 2, 2004 Author Posted April 2, 2004 What Run ( * ) command would I run to turn on the Task Manager? Thanks
Developers Jos Posted April 2, 2004 Developers Posted April 2, 2004 just run taskmgr.exe: run("taskmgr.exe","",@SW_HIDE) Sleep(1000) while 1 $rc = StatusBarGetText("Windows Task Manager","",2) msgbox(0,'cpu usage',$rc) wend SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
esfalk Posted April 2, 2004 Author Posted April 2, 2004 Thanks, I knew someone would know that off the top of their head.
scriptkitty Posted April 2, 2004 Posted April 2, 2004 (edited) Yea I like Jdeb's aproach but with a constant look: run("taskmgr.exe","",@SW_HIDE) Sleep(1000) while 1 $rc = StatusBarGetText("Windows Task Manager","",2) Tooltip($rc,0,0) sleep(10) wend I might write this into a adlib function edit.. did it: AdlibEnable ("cpuuse",10) Run("taskmgr.exe","",@SW_HIDE) Sleep(1000) while 1 sleep(10); or whatever the script Wend Func cpuuse() $rc = StatusBarGetText("Windows Task Manager","",2) Tooltip($rc,0,0) EndFunc Edited April 2, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
esfalk Posted April 2, 2004 Author Posted April 2, 2004 (edited) I threw this together as a function I'm calling to check if my computer's busy. Essentially, it checks Task Manger to keep pc usage under 10%, the mouse cursor for 'wait', and then waits for an expected $window to be activated. Run ( "taskmgr.exe", "", @SW_HIDE ) ; Script that calls _Busy ( ) ; Checks for a busy computer Func _Busy ( $window ) $checka = 1 $checkb = 1 While $checka or $checkb <> 0 $checka = 0 $checkb = 0 $pc = 100 While $pc > 10 Sleep ( 100 ) $pc = StatusBarGetText("Windows Task Manager","",2) StringTrimRight ( $pc, 1 ) If $pc > 10 Then $checka = 1 EndIf Wend While MouseGetCursor ( ) = 15 Sleep ( 100 ) $checkb = 1 Wend WinWaitActive ( $window ) Wend EndFunc Now, is there a way to change my _Busy( $window ) to _Busy ( $window, [$wait] ); essentially with an optional passing of $wait as a timeout on the WinWaitActive? Edited April 2, 2004 by esfalk
Developers Jos Posted April 3, 2004 Developers Posted April 3, 2004 (edited) couple of remarks for you: - only start taskmsg if not running yet: if not ProcessExists("taskmgr.exe" ) then run("taskmgr.exe","",@SW_HIDE) - your while is coded strange but does work: While $checka or $checkb <> 0 this test for $checha = 1 or $checkb <> 0 what about: While $checka or $checkb - this statement doesn't do anything: StringTrimRight ( $pc, 1 ) replace it with: $pc = StringTrimRight( $pc, 1) ; remove the % $pc = StringRight ( $pc, 3 ) ; get the possible 3 digits $pc = int(StringReplace($pc,":","")) ; remove the colon and convert to int. - your function will only check the CPU and mouse once and then will go into waiting mode for the window. in other words the first While doesn't do anything. A User function cannot have optional parameters, but you could just define the $wait period before you call _Busy... Here is an alternate version: Func _Busy( $WINDOW ) Do Do Sleep( 100 ) $PC = StatusbarGetText("Windows Task Manager","",2) $PC = StringTrimRight( $PC, 1) ; remove the % $PC = StringRight( $PC, 3 ) ; get the possible 3 digits $PC = Int(StringReplace($PC,":","")); remove colon and convert to int. Until $PC < 10 Do Sleep( 100 ) Until MouseGetCursor( ) <> 15 Until WinActive($WINDOW) EndFunc ;==>_Busy Edited April 3, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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