Function Reference


_WinAPI_WaitSystemIdle

Wait both Processor and Disk IO are idle.

#include <WinAPISys.au3>
_WinAPI_WaitSystemIdle ( $bToolTip = False, $nMaxLoops = Default, $fSystemPercent = 1.0, $fIOPercent = 1.0, $iRefresh = 2 )

Parameters

$bToolTip to display a tooltip of the Processor or Disk IO usage (Default no display)
$nMaxLoops max number of evaluations (Default no Check)
$fSystemPercent the counting will stop if the current Processor usage is below.
$fIOPercent the counting will stop if the current Disk IO usage is below.
$iRefresh the time between to evaluation (Default = 2 Sec).

Return Value

Success: the number of time Processor usage was above $fSystemPercent ($fSystemPercent Default is 1.0).
@extended is the number of time Disk IO usage was above $fIOPercent ($fIOPercent Default is 1.0).
Failure: Sets the @error flag if number of evaluation exceed.

Remarks

During the Loops the User inputs are disabled : BlockInput($BI_DISABLE).
Unless strange behavior evaluation for Disk IO Usage percent will not be effective.

Related

_WinAPI_QueryProcessorUsage, _WinAPI_QueryDiskUsage

Example

#AutoIt3Wrapper_AutoIt3Dir = e:\trunk.SVN\Bin

#pragma compile(AutoItExecuteAllowed, True)

;~ #include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>

; create a script which use CPU
Local $sTestAu3 = @TempDir & "\TestSystemIdle.au3"
FileDelete($sTestAu3)
FileWriteLine($sTestAu3, 'For $i = 1 To 50000000')
FileWriteLine($sTestAu3, '$i = $i')
FileWriteLine($sTestAu3, 'Next')

;~ Local $sTestAu3 = @TempDir & "\TestIOIdle.au3"
;~ FileDelete($sTestAu3)
;~ FileWriteLine($sTestAu3, 'For $i = 1 To 100000')
;~ FileWriteLine($sTestAu3, 'FileRead(@ScriptFullPath)')
;~ FileWriteLine($sTestAu3, 'Next')

If @Compiled Then
    Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sTestAu3 & '"')
Else
    Run(@AutoItExe & " " & $sTestAu3)
EndIf

Local $hTimer = TimerInit()
Local $nSleep = _WinAPI_WaitSystemIdle(True)
Local $iExtended = @extended
Local $sElapse = Round(TimerDiff($hTimer) / 1000, 2)

FileDelete($sTestAu3)

MsgBox($MB_TOPMOST, 'Test duration', $sElapse & " sec (" & $nSleep & "/" & $iExtended & ')')