66
77#Tidy_Parameters= / tcb= - 1
88
9- ; NetWebView2Lib.au3 - Script Version: 2026.3.17.22 🚩
9+ ; NetWebView2Lib.au3 - Script Version: 2.2.1-alpha ( 2026.03.20.09) 🚩
1010
1111#include < Array.au3>
1212#include < GUIConstantsEx.au3>
@@ -443,15 +443,15 @@ Func _NetWebView2_GetVersion($oWebV2M)
443443EndFunc ; ==>_NetWebView2_GetVersion
444444
445445; #FUNCTION# ====================================================================================================================
446- ; Name. ..........: _NetWebView2_LoadWait
447- ; Description. ...: Waits for a specific WebView2 status or event with a timeout.
446+ ; Name ..........: _NetWebView2_LoadWait
447+ ; Description ...: Waits for a specific WebView2 status or event with a timeout.
448448; Syntax ........: _NetWebView2_LoadWait($oWebV2M[, $iWaitMessage = $NETWEBVIEW2_MESSAGE__TITLE_CHANGED[, $sExpectedTitle = ""[,
449449; $iTimeOut_ms = 5000]]])
450- ; Parameters. ....: $oWebV2M - The NetWebView2 Manager object.
450+ ; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
451451; $iWaitMessage - The status code to wait for (Default is $NETWEBVIEW2_MESSAGE__TITLE_CHANGED).
452452; $sExpectedTitle - [optional] Expected title to LoadWait for, as StringRegExp() pattern
453453; $iTimeOut_ms - [optional] Maximum time to wait in milliseconds. 0 for infinite. Default is 5000ms
454- ; Return values. .: Success - True
454+ ; Return values .: Success - True
455455; Failure - False and sets @error:
456456; 3 - Navigation Error ($NETWEBVIEW2_MESSAGE__NAV_ERROR)
457457; 4 - Timeout reached
@@ -529,16 +529,16 @@ Func _NetWebView2_LoadWait($oWebV2M, $iWaitMessage = $NETWEBVIEW2_MESSAGE__TITLE
529529EndFunc ; ==>_NetWebView2_LoadWait
530530
531531; #FUNCTION# ====================================================================================================================
532- ; Name. ..........: _NetWebView2_Navigate
533- ; Description. ...: Navigates to a URL and waits for a specific completion status.
532+ ; Name ..........: _NetWebView2_Navigate
533+ ; Description ...: Navigates to a URL and waits for a specific completion status.
534534; Syntax ........: _NetWebView2_Navigate($oWebV2M, $s_URL[, $iWaitMessage = $NETWEBVIEW2_MESSAGE__TITLE_CHANGED[,
535535; $sExpectedTitle = ""[, $iTimeOut_ms = 5000]]])
536- ; Parameters. ....: $oWebV2M - The NetWebView2 Manager object.
536+ ; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
537537; $s_URL - The URL to navigate to.
538538; $iWaitMessage - The status code to wait for (Default is $NETWEBVIEW2_MESSAGE__TITLE_CHANGED).
539539; $sExpectedTitle - [optional] Expected title to LoadWait for, as StringRegExp() pattern
540540; $iTimeOut_ms - [optional] Maximum time to wait in milliseconds. 0 for infinite. Default is 5000ms
541- ; Return values. .: Success - True
541+ ; Return values .: Success - True
542542; Failure - False and sets @error:
543543; 1 - Invalid parameters
544544; 2 - Navigation call failed (COM error)
@@ -567,7 +567,10 @@ Func _NetWebView2_Navigate($oWebV2M, $s_URL, $iWaitMessage = $NETWEBVIEW2_MESSAG
567567 ; The Local Error Handler catches potential "Disposed Object" crashes here
568568 $oWebV2M .LockWebView()
569569 $oWebV2M .Navigate($s_URL )
570- If @error Then Return SetError (2 , @error , False )
570+ If @error Then
571+ $oWebV2M .UnLockWebView()
572+ Return SetError (2 , @error , False )
573+ EndIf
571574
572575 ; 3. Wait for status using the Bulletproof LoadWait logic
573576 Local $bResult = _NetWebView2_LoadWait($oWebV2M , $iWaitMessage , $sExpectedTitle , $iTimeOut_ms )
@@ -616,6 +619,7 @@ Func _NetWebView2_NavigateToString($oWebV2M, $s_HTML, $iWaitMessage = $NETWEBVIE
616619 Local $iNavigation = $oWebV2M .NavigateToString($s_HTML )
617620 Local $iErr = @error , $iExt = @extended
618621 If @error Then
622+ $oWebV2M .UnLockWebView()
619623 Return SetError ($iErr , $iExt , $iNavigation )
620624 Else
621625 _NetWebView2_LoadWait($oWebV2M , $iWaitMessage , $sExpectedTitle , $iTimeOut_ms )
@@ -633,7 +637,7 @@ EndFunc ;==>_NetWebView2_NavigateToString
633637#Region ; === NetWebView2Lib UDF === _NetWebView2_* helper functions
634638; #FUNCTION# ====================================================================================================================
635639; Name ..........: _NetWebView2_BrowserSetupWrapper
636- ; Description ...:
640+ ; Description ...: Sets up and initializes a browser window using the specified profile and settings.
637641; Syntax ........: _NetWebView2_BrowserSetupWrapper($hOuterParentWindow, ByRef $oOuterWeb, $sEventPrefix, $sProfile,
638642; ByRef $oOuterBridge, ByRef $hInnerWebViewWindow, $iX, $iY, $iW, $iH, $s_AddBrowserArgs)
639643; Parameters ....: $hOuterParentWindow - a handle value.
@@ -671,7 +675,7 @@ EndFunc ;==>_NetWebView2_BrowserSetupWrapper
671675
672676; #FUNCTION# ====================================================================================================================
673677; Name ..........: _NetWebView2_ExportPageData
674- ; Description ...:
678+ ; Description ...: Captures page data using Chrome DevTools Protocol. Can return MHTML or other CDP formats based on the `cdpParameters` JSON string.
675679; Syntax ........: _NetWebView2_ExportPageData($oWebV2M, $iFormat[, $sFilePath = ''])
676680; Parameters ....: $oWebV2M - an object.
677681; $iFormat - a string value. 0 HTML only, 1 MHTML Snapshot
@@ -699,7 +703,7 @@ EndFunc ;==>_NetWebView2_ExportPageData
699703
700704; #FUNCTION# ====================================================================================================================
701705; Name ..........: _NetWebView2_GetSource
702- ; Description ...:
706+ ; Description ...: Returns the current URL of the browser.
703707; Syntax ........: _NetWebView2_GetSource($oWebV2M)
704708; Parameters ....: $oWebV2M - an object.
705709; Return values .: None
@@ -819,9 +823,9 @@ EndFunc ;==>_NetWebView2_PrintToPdfStream
819823
820824#Region ; === NetWebView2Lib UDF === New Core Method Wrappers
821825; #FUNCTION# ====================================================================================================================
822- ; Name. ..........: _NetWebView2_AddInitializationScript
826+ ; Name ..........: _NetWebView2_AddInitializationScript
823827; Description ...: Adds a JavaScript to be executed before any other script when a new page is loaded.
824- ; Syntax. ........: _NetWebView2_AddInitializationScript($oWeb, $sScript)
828+ ; Syntax ........: _NetWebView2_AddInitializationScript($oWeb, $sScript)
825829; Parameters ....: $oWeb - The NetWebView2 Manager object.
826830; $vScript - The JavaScript code to inject (String) OR the full path to a JavaScript file.
827831; Return values .: Success - Returns a Script ID (string).
@@ -845,10 +849,10 @@ Func _NetWebView2_AddInitializationScript($oWebV2M, $vScript)
845849EndFunc ; ==>_NetWebView2_AddInitializationScript
846850
847851; #FUNCTION# ====================================================================================================================
848- ; Name. ..........: _NetWebView2_RemoveInitializationScript
849- ; Description. ...: Removes a previously added initialization script using its ID.
850- ; Syntax. ........: _NetWebView2_RemoveInitializationScript($oWebV2M, $sScriptId)
851- ; Parameters. ....: $oWebV2M - The Net WebView2 instance to manipulate.
852+ ; Name ..........: _NetWebView2_RemoveInitializationScript
853+ ; Description ...: Removes a previously added initialization script using its ID.
854+ ; Syntax ........: _NetWebView2_RemoveInitializationScript($oWebV2M, $sScriptId)
855+ ; Parameters ....: $oWebV2M - The Net WebView2 instance to manipulate.
852856; $sScriptId - The ID of the initialization script to remove.
853857; Return values .: Success - True
854858; Failure - False and sets @error
@@ -866,9 +870,9 @@ Func _NetWebView2_RemoveInitializationScript($oWebV2M, $sScriptId)
866870EndFunc ; ==>_NetWebView2_RemoveInitializationScript
867871
868872; #FUNCTION# ====================================================================================================================
869- ; Name. ..........: _NetWebView2_SetVirtualHostNameToFolderMapping
873+ ; Name ..........: _NetWebView2_SetVirtualHostNameToFolderMapping
870874; Description ...: Maps a custom host name to a local folder path (bypasses CORS).
871- ; Syntax. ........: _NetWebView2_SetVirtualHostNameToFolderMapping($oWebV2M, $sHostName, $sFolderPath[, $iAccessKind = 0])
875+ ; Syntax ........: _NetWebView2_SetVirtualHostNameToFolderMapping($oWebV2M, $sHostName, $sFolderPath[, $iAccessKind = 0])
872876; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
873877; $sHostName - The virtual domain (e.g., "myapp.local").
874878; $sFolderPath - The absolute path to the local folder.
@@ -889,9 +893,9 @@ Func _NetWebView2_SetVirtualHostNameToFolderMapping($oWebV2M, $sHostName, $sFold
889893EndFunc ; ==>_NetWebView2_SetVirtualHostNameToFolderMapping
890894
891895; #FUNCTION# ====================================================================================================================
892- ; Name. ..........: _NetWebView2_SetLockState
896+ ; Name ..........: _NetWebView2_SetLockState
893897; Description ...: Locks or unlocks the manager to prevent COM calls during critical operations (e.g., Cleanup).
894- ; Syntax. ........: _NetWebView2_SetLockState($oWebV2M, $bLockState)
898+ ; Syntax ........: _NetWebView2_SetLockState($oWebV2M, $bLockState)
895899; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
896900; $bLockState - True to lock (prevent calls), False to unlock.
897901; Return values .: Success - True
@@ -910,9 +914,9 @@ Func _NetWebView2_SetLockState($oWebV2M, $bLockState)
910914EndFunc ; ==>_NetWebView2_SetLockState
911915
912916; #FUNCTION# ====================================================================================================================
913- ; Name. ..........: _NetWebView2_EncodeBinaryToB64
917+ ; Name ..........: _NetWebView2_EncodeBinaryToB64
914918; Description ...: High-performance binary to Base64 string encoding using the C# Core.
915- ; Syntax. ........: _NetWebView2_EncodeBinaryToB64($oWebV2M, ByRef $dBinary)
919+ ; Syntax ........: _NetWebView2_EncodeBinaryToB64($oWebV2M, ByRef $dBinary)
916920; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
917921; $dBinary - The binary data to encode.
918922; Return values .: Success - Returns a Base64 encoded string.
@@ -932,9 +936,9 @@ Func _NetWebView2_EncodeBinaryToB64($oWebV2M, ByRef $dBinary)
932936EndFunc ; ==>_NetWebView2_EncodeBinaryToB64
933937
934938; #FUNCTION# ====================================================================================================================
935- ; Name. ..........: _NetWebView2_DecodeB64ToBinary
939+ ; Name ..........: _NetWebView2_DecodeB64ToBinary
936940; Description ...: High-performance Base64 string to binary data decoding using the C# Core.
937- ; Syntax. ........: _NetWebView2_DecodeB64ToBinary($oWebV2M, ByRef $sB64)
941+ ; Syntax ........: _NetWebView2_DecodeB64ToBinary($oWebV2M, ByRef $sB64)
938942; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
939943; $sB64 - The Base64 encoded string to decode.
940944; Return values .: Success - Returns binary data.
@@ -954,9 +958,9 @@ Func _NetWebView2_DecodeB64ToBinary($oWebV2M, ByRef $sB64)
954958EndFunc ; ==>_NetWebView2_DecodeB64ToBinary
955959
956960; #FUNCTION# ====================================================================================================================
957- ; Name. ..........: _NetWebView2_SetBuiltInErrorPageEnabled
961+ ; Name ..........: _NetWebView2_SetBuiltInErrorPageEnabled
958962; Description ...: Enables or disables the built-in WebView2 error pages (e.g., "No Internet").
959- ; Syntax. ........: _NetWebView2_SetBuiltInErrorPageEnabled($oWeb, $bEnabled)
963+ ; Syntax ........: _NetWebView2_SetBuiltInErrorPageEnabled($oWeb, $bEnabled)
960964; Parameters ....: $oWeb - The NetWebView2 Manager object.
961965; $bEnabled - True to show default error pages, False to hide them.
962966; Return values .: Success - True
@@ -975,11 +979,11 @@ Func _NetWebView2_SetBuiltInErrorPageEnabled($oWebV2M, $bEnabled)
975979EndFunc ; ==>_NetWebView2_SetBuiltInErrorPageEnabled
976980
977981; #FUNCTION# ====================================================================================================================
978- ; Name. ..........: _WebView2_FrameGetHtmlSource
979- ; Description. ...: Synchronously retrieves the full HTML source of a frame.
980- ; Syntax. ........: _WebView2_FrameGetHtmlSource($oFrame)
981- ; Parameters. ....: $oFrame - The WebView2Frame object.
982- ; Return values. .: Success - Clean HTML string.
982+ ; Name ..........: _WebView2_FrameGetHtmlSource
983+ ; Description ...: Synchronously retrieves the full HTML source of a frame.
984+ ; Syntax ........: _WebView2_FrameGetHtmlSource($oFrame)
985+ ; Parameters ....: $oFrame - The WebView2Frame object.
986+ ; Return values .: Success - Clean HTML string.
983987; Failure - Sets @error and returns empty string.
984988; Author ........: ioa747
985989; Modified ......:
@@ -1177,8 +1181,8 @@ Func __NetWebView2_WaitForReadyState($oWebV2M, $hTimer, $iTimeOut_ms = 5000)
11771181EndFunc ; ==>__NetWebView2_WaitForReadyState
11781182
11791183; #INTERNAL_USE_ONLY# ===========================================================================================================
1180- ; Name. ..........: __NetWebView2_LastMessage_KEEPER
1181- ; Description. ...: Centralized state manager for WebView2 instances using a static map.
1184+ ; Name ..........: __NetWebView2_LastMessage_KEEPER
1185+ ; Description ...: Centralized state manager for WebView2 instances using a static map.
11821186; Syntax ........: __NetWebView2_LastMessage_KEEPER($oWebV2M[, $iMessage = Default[, $iError = @error[, $iExtended = @extended]]])
11831187; Parameters ....: $oWebV2M - The NetWebView2 Manager object.
11841188; $iMessage - [optional] Message to SET. If Default, function acts as GET. If -1, performs cleanup.
@@ -1502,9 +1506,9 @@ EndFunc ;==>__NetWebView2_freezer
15021506
15031507#Region ; === NetWebView2Lib UDF === EVENT HANDLERS === Error Handlers ===
15041508; #INTERNAL_USE_ONLY# ===========================================================================================================
1505- ; Name. ..........: __NetWebView2_SilentErrorHandler
1506- ; Description. ...: A generic COM Error Handler that silences errors.
1507- ; Syntax. ........: __NetWebView2_SilentErrorHandler()
1509+ ; Name ..........: __NetWebView2_SilentErrorHandler
1510+ ; Description ...: A generic COM Error Handler that silences errors.
1511+ ; Syntax ........: __NetWebView2_SilentErrorHandler()
15081512; Remarks........: Used to prevent script crashes when a WebView2 object is disposed or closed
15091513; while an event or a method call is still in progress.
15101514; Author ........: ioa747, mLipok
@@ -2202,7 +2206,7 @@ EndFunc ;==>__NetWebView2_Events__OnProcessFailed
22022206
22032207; #INTERNAL_USE_ONLY# ===========================================================================================================
22042208; Name ..........: __NetWebView2_Events__OnBasicAuthenticationRequested
2205- ; Description ...: event is raised when WebView encounters a Basic HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Authentication, a Digest HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Headers/Authorization#digest, an NTLM authentication or a Proxy Authentication request.
2209+ ; Description ...: event is raised when WebView encounters a Basic HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Authentication, a Digest HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Headers/Authorization#digest, an NTLM authentication or a Proxy Authentication request.
22062210; Syntax ........: __NetWebView2_Events__OnBasicAuthenticationRequested($oWebV2M, $hGUI, $oArgs)
22072211; Parameters ....: $oWebV2M - an object.
22082212; $hGUI - a handle value.
0 commit comments