警告:此函数是实验性的. 可能无法正常工作, 也可能包含错误. 如以后被修改或删除, 恕不另行通知.
不要报告此函数的错误或请求新的功能.
Volatile
函数的限定符.
Volatile Func functioname(...)
...
EndFunc
备注
使用 Volatile 限定符修改函数执行的某些方面.
以下规则适用于用此限定符声明函数:
回调函数
|
函数执行的主要 AutoIt 消息泵不堵塞, 因为它通常是非.
|
COM 事件函数
|
执行是同步的 (见示例).
|
SetTimer 不是作为安全的易失性回调, 所以一定要避免它们.
对于所有其它情况, 在执行易失函数比较 正规 函数没有任何区别.
相关
Func
函数示例
_COM_Example()
Func _COM_Example()
; Create Internet Explorer object
Local $oIE = ObjCreate("InternetExplorer.Application")
; Check for errors
If @error Then Return
$oIE.Visible = True ; set visibility
; Custom sink object
ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
; Navigate somewhere
$oIE.navigate("http://www.google.com")
; Check for errors while loading
If @error Then
$oIE.Quit()
Return
EndIf
; Wait for page to load
While 1
If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop
Sleep(10)
WEnd
; Wait few seconds to see if more events will be fired
Sleep(3000)
; Nothing more to do. Close IE and return from the function
$oIE.Quit()
EndFunc ;==>_COM_Example
; BeforeNavigate2 method definition
Volatile Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, ByRef $bIECancel)
ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--BeforeNavigate2 fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
"$oIEpDisp = " & $oIEpDisp() & " - " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object
"$sIEURL = " & $sIEURL & @CRLF & _
"$iIEFlags = " & $iIEFlags & @CRLF & _
"$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _
"$sIEPostData = " & $sIEPostData & @CRLF & _
"$iIEHeaders = " & $iIEHeaders & @CRLF & _
"$bIECancel = " & $bIECancel & @CRLF & _
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)
; Cancel navigation
$bIECancel = True
EndFunc ;==>_IEEvent_BeforeNavigate2
----------------------------------------
|