AdlibRegister
注册 Adlib 函数.
AdlibRegister ( "function" [, time = 250] )
参数
function
|
注册的 Adlib 函数的名称.
|
time
|
[可选] 调用 Adlib 函数的间隔时间(毫秒). 默认为 250 毫秒.
|
返回值
备注
每 250 毫秒 (或指定的时间) 调用注册的函数--通常用于检查意外错误.
例如, 可以使用 Adlib 函数处理脚本中不可预知的错误弹出窗口.
Adlib 函数应尽可能的简单, 因为它要频繁地执行,而且在执行期间主脚本将被暂停.
另外, 应小心使用“时间”参数, 以免 CPU 负荷过高.
你不能使用参数注册函数.
可以注册多个 Adlib 函数. 重新注册已经存在的 Adlib 函数将更新该函数的调用时间.
相关
AdlibUnRegister
函数示例
#include <MsgBoxConstants.au3>
If ProcessExists("SciTE.exe") = 0 Then
MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.")
EndIf
Example()
Func Example()
; Register the function MyAdLibFunc() to be called every 250ms (default).
AdlibRegister("MyAdLibFunc")
; Sleep does not stop AdLib functions from running.
Sleep(1000)
; AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc.
MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.")
; The AdLib function MyAdLibFunc() will start again.
Sleep(2000)
; Unregister the function MyAdLibFunc() from being called every 250ms.
AdlibUnRegister("MyAdLibFunc")
EndFunc ;==>Example
Func MyAdLibFunc()
; Assign a static variable to hold the number of times the function is called.
Local Static $iCount = 0
$iCount += 1
ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF)
EndFunc ;==>MyAdLibFunc
----------------------------------------
|