Skip to content

Commit 16c4532

Browse files
authored
2026.2.16.20
1 parent 03bd791 commit 16c4532

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

NetWebView2Lib.au3

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#Tidy_Parameters=/tcb=-1
88

9-
; NetWebView2Lib.au3 - Script Version: 2026.2.16.3 🚩
9+
; NetWebView2Lib.au3 - Script Version: 2026.2.16.20 🚩
1010

1111
#include <Array.au3>
1212
#include <GUIConstantsEx.au3>
@@ -822,7 +822,7 @@ EndFunc ;==>_NetWebView2_PrintToPdfStream
822822
; Description ...: Adds a JavaScript to be executed before any other script when a new page is loaded.
823823
; Syntax.........: _NetWebView2_AddInitializationScript($oWeb, $sScript)
824824
; Parameters ....: $oWeb - The NetWebView2 Manager object.
825-
; $sScript - The JavaScript code to inject.
825+
; $vScript - The JavaScript code to inject (String) OR the full path to a JavaScript file.
826826
; Return values .: Success - Returns a Script ID (string).
827827
; Failure - Returns the error message and sets @error.
828828
; Author ........: ioa747, mLipok
@@ -832,12 +832,16 @@ EndFunc ;==>_NetWebView2_PrintToPdfStream
832832
; Link ..........:
833833
; Example .......: No
834834
; ===============================================================================================================================
835-
Func _NetWebView2_AddInitializationScript($oWebV2M, $sScript)
835+
Func _NetWebView2_AddInitializationScript($oWebV2M, $vScript)
836836
If (Not IsObj($oWebV2M)) Or ObjName($oWebV2M, $OBJ_PROGID) <> 'NetWebView2.Manager' Then Return SetError(1, 0, "ERROR: Invalid Object")
837-
Local $sScriptId = $oWebV2M.AddInitializationScript($sScript)
837+
838+
; Smart Detection
839+
If FileExists($vScript) Then $vScript = FileRead($vScript)
840+
841+
Local $sScriptId = $oWebV2M.AddInitializationScript($vScript)
838842
If StringInStr($sScriptId, "ERROR:") Then Return SetError(2, 0, $sScriptId)
839843
Return SetError(0, 0, $sScriptId)
840-
EndFunc ;==>_NetWebView2_AddInitializationScript
844+
EndFunc ;==>New_NetWebView2_AddInitializationScript
841845

842846
; #FUNCTION# ====================================================================================================================
843847
; Name...........: _NetWebView2_RemoveInitializationScript
@@ -2149,3 +2153,4 @@ EndFunc ;==>__NetWebView2_Events__OnScreenCaptureStarting
21492153
#EndRegion ; NetWebView2Lib UDF - === EVENT HANDLERS ===
21502154

21512155

2156+

0 commit comments

Comments
 (0)