Skip to content

Commit 4b1cf17

Browse files
authored
Update NetWebView2Lib.au3
1 parent f8fd0fe commit 4b1cf17

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

NetWebView2Lib.au3

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ Global Enum _ ; $NETWEBVIEW2_MESSAGE__* are set by __NetWebView2_Events__OnMessa
7373
$NETWEBVIEW2_MESSAGE__BROWSER_LOST_FOCUS, _
7474
$NETWEBVIEW2_MESSAGE___FAKE_COUNTER
7575

76+
Global Enum _
77+
$NETWEBVIEW2_EXECUTEJS_MODE0_FIREANDFORGET, _
78+
$NETWEBVIEW2_EXECUTEJS_MODE1_ASYNC, _
79+
$NETWEBVIEW2_EXECUTEJS_MODE2_RESULT, _
80+
$NETWEBVIEW2_ExecuteJS__FAKE_COUNTER
81+
7682
#Region ; NetWebView2Lib UDF - _NetWebView2_* core functions
7783
; #FUNCTION# ====================================================================================================================
7884
; Name ..........: _NetWebView2_Initialize
@@ -206,21 +212,21 @@ EndFunc ;==>_NetWebView2_GetBridge
206212
; Syntax ........: _NetWebView2_ExecuteScript($oWebV2M, $sJavaScript[, $iMode = 0])
207213
; Parameters ....: $oWebV2M - an object.
208214
; $sJavaScript - a string value.
209-
; $iMode - [optional] One of the following search modes:
210-
; |0 - Execute, do not wait "Fire-and-Forget" - Default
211-
; |1 - ExecuteScriptOnPage "Async-Void Trap"
212-
; |2 - ExecuteScriptWithResult - This is the only method designed to return data
215+
; $iMode - [optional] Default is $NETWEBVIEW2_EXECUTEJS_MODE0_FIREANDFORGET. One of the following search modes:
216+
; |0 - $NETWEBVIEW2_EXECUTEJS_MODE0_FIREANDFORGET - Execute, do not wait "Fire-and-Forget"
217+
; |1 - $NETWEBVIEW2_EXECUTEJS_MODE1_ASYNC - ExecuteScriptOnPage "Async-Void Trap"
218+
; |2 - $NETWEBVIEW2_EXECUTEJS_MODE2_RESULT - ExecuteScriptWithResult - This is the only method designed to return data
213219
; Return values .: None
214220
; Author ........: mLipok, ioa747
215221
; Modified ......:
216222
; Remarks .......: $iMode additionall information:
217-
; 0. ExecuteScript (Fire-and-Forget)
223+
; $NETWEBVIEW2_EXECUTEJS_MODE0_FIREANDFORGET - ExecuteScript (Fire-and-Forget)
218224
; In the C# bridge, this is defined as a public void. It uses _webView.Invoke to send the command to the UI thread and exits immediately. It does not wait for the JavaScript to execute, and it has no return type.
219225
; Use case: Clicking buttons, scrolling, or triggering JS events where you don't care about the result.
220-
; 1. ExecuteScriptOnPage (Async-Void Trap)
226+
; $NETWEBVIEW2_EXECUTEJS_MODE1_ASYNC - ExecuteScriptOnPage (Async-Void Trap)
221227
; This is defined as public async void. In COM Interop (which AutoIt uses), an async void method returns control to the caller (AutoIt) the moment it hits the first internal await. The script runs in the background, but the result is never passed back to the COM interface.
222228
; Use case: Fast execution where background processing is acceptable, but again, no return value.
223-
; 2. ExecuteScriptWithResult
229+
; $NETWEBVIEW2_EXECUTEJS_MODE2_RESULT - ExecuteScriptWithResult
224230
; This is the only method designed to return data. It implements a Message Pump (using Application.DoEvents()) to keep the interface responsive while waiting up to 5 seconds for the result.
225231
; Key Features of ExecuteScriptWithResult:
226232
; Blocking: It waits for the script to finish (Sync-like behavior for AutoIt).
@@ -230,7 +236,7 @@ EndFunc ;==>_NetWebView2_GetBridge
230236
; Link ..........: https://github.com/ioa747/NetWebView2Lib/issues/45#issuecomment-3831184514
231237
; Example .......: No
232238
; ===============================================================================================================================
233-
Func _NetWebView2_ExecuteScript($oWebV2M, $sJavaScript, $iMode = 0)
239+
Func _NetWebView2_ExecuteScript($oWebV2M, $sJavaScript, $iMode = $NETWEBVIEW2_EXECUTEJS_MODE0_FIREANDFORGET)
234240
Local Const $s_Prefix = "[_NetWebView2_ExecuteScript]:" & " TYPE: " & $iMode
235241
Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) ; Local COM Error Handler
236242
#forceref $oMyError

0 commit comments

Comments
 (0)