@@ -100,7 +100,7 @@ Global Enum _ ; $NETWEBVIEW2_MESSAGE__* are set by __NetWebView2_Events__OnMessa
100100; Example .......: No
101101; ===============================================================================================================================
102102Func _NetWebView2_Initialize($oWebV2M , $hGUI , $s_ProfileDirectory , $i_Left = 0 , $i_Top = 0 , $i_Width = 0 , $i_Height = 0 , $b_LoadWait = True , $b_SetAutoResize = True , $b_DevToolsEnabled = True , $i_ZoomFactor = 1.0 , $s_BackColor = " 0x2B2B2B" , $b_InitConsole = False )
103- Local Const $s_Prefix = " [_NetWebView2_Initialize]:" & " GUI:" & $hGUI & " ProfileDirectory:" & $s_ProfileDirectory & " LEFT:" & $i_Left & " TOP:" & $i_Top & " WIDTH" & $i_Width & " HEIGHT:" & $i_Height & " LOADWAIT:" & $b_LoadWait & " SETAUTORESIZE:" & $b_SetAutoResize & " SetAutoResize:" & $b_DevToolsEnabled & " ZoomFactor:" & $i_ZoomFactor & " BackColor:" & $s_BackColor
103+ Local Const $s_Prefix = " [_NetWebView2_Initialize]: GUI:" & $hGUI & " ProfileDirectory:" & $s_ProfileDirectory & " LEFT:" & $i_Left & " TOP:" & $i_Top & " WIDTH" & $i_Width & " HEIGHT:" & $i_Height & " LOADWAIT:" & $b_LoadWait & " SETAUTORESIZE:" & $b_SetAutoResize & " SetAutoResize:" & $b_DevToolsEnabled & " ZoomFactor:" & $i_ZoomFactor & " BackColor:" & $s_BackColor
104104
105105 ; ⚠️ Important: Enclose ($hGUI) in parentheses to force "Pass-by-Value".
106106 ; This prevents the COM layer from changing the AutoIt variable type from Ptr to Int64.
@@ -143,7 +143,7 @@ EndFunc ;==>_NetWebView2_Initialize
143143; Example .......: No
144144; ===============================================================================================================================
145145Func _NetWebView2_CreateManager($sUserAgent = ' ' , $s_fnEventPrefix = " " , $s_AddBrowserArgs = " " )
146- Local Const $s_Prefix = " [_NetWebView2_CreateManager]:"
146+ Local Const $s_Prefix = " [_NetWebView2_CreateManager]: fnEventPrefix= " & $s_fnEventPrefix & " AddBrowserArgs= " & $s_AddBrowserArgs
147147 Local $oMyError = ObjEvent (" AutoIt.Error" , __NetWebView2_COMErrFunc) ; Local COM Error Handler
148148 #forceref $oMyError
149149
@@ -162,10 +162,6 @@ Func _NetWebView2_CreateManager($sUserAgent = '', $s_fnEventPrefix = "", $s_AddB
162162 EndIf
163163 ObjEvent ($oWebV2M , " __NetWebView2_Events__" , " IWebViewEvents" )
164164
165- If $s_fnEventPrefix <> " " Then
166- ObjEvent ($oWebV2M , $s_fnEventPrefix , " IWebViewEvents" )
167- EndIf
168-
169165 Return SetError (@error , @extended , $oWebV2M )
170166EndFunc ; ==>_NetWebView2_CreateManager
171167
@@ -201,10 +197,6 @@ Func _NetWebView2_GetBridge($oWebV2M, $s_fnEventPrefix = "")
201197 EndIf
202198 ObjEvent ($oWebJS , " __NetWebView2_JSEvents__" , " IBridgeEvents" )
203199
204- If $s_fnEventPrefix <> " " Then
205- ObjEvent ($oWebJS , $s_fnEventPrefix , " IBridgeEvents" )
206- EndIf
207-
208200 Return SetError (@error , @extended , $oWebJS )
209201EndFunc ; ==>_NetWebView2_GetBridge
210202
@@ -303,7 +295,7 @@ EndFunc ;==>_NetWebView2_CleanUp
303295; Example .......: No
304296; ===============================================================================================================================
305297Func _NetWebView2_LoadWait($oWebV2M , $iWaitMessage = $NETWEBVIEW2_MESSAGE__INIT_READY , $iTimeOut_ms = 0 )
306- Local Const $s_Prefix = " [_NetWebView2_LoadWait]: iStatus:" & $iWaitMessage
298+ Local Const $s_Prefix = " [_NetWebView2_LoadWait]: iStatus:" & $iWaitMessage & " TimeOut_ms= " & $iTimeOut_ms
307299 Local $oMyError = ObjEvent (" AutoIt.Error" , __NetWebView2_COMErrFunc) ; Local COM Error Handler
308300 #forceref $oMyError
309301
@@ -364,7 +356,7 @@ EndFunc ;==>_NetWebView2_LoadWait
364356; Example .......: No
365357; ===============================================================================================================================
366358Func _NetWebView2_Navigate($oWebV2M , $sURL , $iWaitMessage = $NETWEBVIEW2_MESSAGE__TITLE_CHANGED , $iTimeOut_ms = 0 )
367- Local Const $s_Prefix = " [_NetWebView2_LoadWait]: URL:" & $sURL & " WAIT:" & $iWaitMessage
359+ Local Const $s_Prefix = " [_NetWebView2_LoadWait]: URL:" & $sURL & " WAIT:" & $iWaitMessage & " TimeOut_ms= " & $iTimeOut_ms
368360 Local $oMyError = ObjEvent (" AutoIt.Error" , __NetWebView2_COMErrFunc) ; Local COM Error Handler
369361 #forceref $oMyError
370362
@@ -405,10 +397,11 @@ EndFunc ;==>_NetWebView2_GetSource
405397; #FUNCTION# ====================================================================================================================
406398; Name ..........: _NetWebView2_NavigateToString
407399; Description ...:
408- ; Syntax ........: _NetWebView2_NavigateToString($oWebV2M, $s_HTML[, $b_LoadWait = True])
400+ ; Syntax ........: _NetWebView2_NavigateToString($oWebV2M, $s_HTML[, $b_LoadWait = True[, $iTimeOut_ms = 5000] ])
409401; Parameters ....: $oWebV2M - an object.
410402; $s_HTML - a string value.
411403; $b_LoadWait - [optional] a boolean value. Default is True.
404+ ; $iTimeOut_ms - [optional] an integer value. Default is 5000.
412405; Return values .: None
413406; Author ........: mLipok, ioa747
414407; Modified ......:
@@ -417,15 +410,15 @@ EndFunc ;==>_NetWebView2_GetSource
417410; Link ..........:
418411; Example .......: No
419412; ===============================================================================================================================
420- Func _NetWebView2_NavigateToString($oWebV2M , $s_HTML , $b_LoadWait = True )
421- Local Const $s_Prefix = " [_NetWebView2_NavigateToString]:" & " HTML Size:" & StringLen ($s_HTML ) & " LoadWait:" & $b_LoadWait
413+ Func _NetWebView2_NavigateToString($oWebV2M , $s_HTML , $b_LoadWait = True , $iTimeOut_ms = 5000 )
414+ Local Const $s_Prefix = " [_NetWebView2_NavigateToString]:" & " HTML Size:" & StringLen ($s_HTML ) & " LoadWait:" & $b_LoadWait & " TimeOut_ms= " & $iTimeOut_ms
422415 Local $oMyError = ObjEvent (" AutoIt.Error" , __NetWebView2_COMErrFunc) ; Local COM Error Handler
423416 #forceref $oMyError
424417
425418 Local $iNavigation = $oWebV2M .NavigateToString($s_HTML )
426419 If @error Then Return SetError (@error , @extended , $iNavigation )
427420
428- If $b_LoadWait Then _NetWebView2_LoadWait($oWebV2M )
421+ If $b_LoadWait Then _NetWebView2_LoadWait($oWebV2M , $NETWEBVIEW2_MESSAGE__TITLE_CHANGED , $iTimeOut_ms )
429422 If @error Then __NetWebView2_Log(@ScriptLineNumber , $s_Prefix , 1 )
430423 Return SetError (@error , @extended , ' ' )
431424EndFunc ; ==>_NetWebView2_NavigateToString
@@ -935,7 +928,7 @@ EndFunc ;==>__NetWebView2_COMErrFunc
935928
936929; Handles native WebView2 events
937930Func __NetWebView2_Events__OnMessageReceived($oWebV2M , $hGUI , $sMsg )
938- Local Const $s_Prefix = " [WebViewEvents__OnMessageReceived]: "
931+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnMessageReceived]: GUI: " & $hGUI
939932
940933 Local $iSplitPos = StringInStr ($sMsg , " |" )
941934 Local $sCommand = $iSplitPos ? StringStripWS (StringLeft ($sMsg , $iSplitPos - 1 ), 3 ) : $sMsg
@@ -1105,7 +1098,7 @@ EndFunc ;==>__NetWebView2_Events__OnMessageReceived
11051098
11061099; Handles custom messages from JavaScript (window.chrome.webview.postMessage)
11071100Func __NetWebView2_JSEvents__OnMessageReceived($oWebV2M , $hGUI , $sMsg )
1108- Local Const $s_Prefix = " [JSEvents__OnMessageReceived]:"
1101+ Local Const $s_Prefix = " [JSEvents__OnMessageReceived]: GUI: " & $hGUI
11091102 Local $oMyError = ObjEvent (" AutoIt.Error" , __NetWebView2_COMErrFunc) ; Local COM Error Handler
11101103 #forceref $oMyError
11111104
@@ -1171,7 +1164,7 @@ Func __NetWebView2_JSEvents__OnMessageReceived($oWebV2M, $hGUI, $sMsg)
11711164EndFunc ; ==>__NetWebView2_JSEvents__OnMessageReceived
11721165
11731166Func __NetWebView2_Events__OnBrowserGotFocus($oWebV2M , $hGUI , $iReason )
1174- Local Const $s_Prefix = " [WebViewEvents__OnBrowserGotFocus]: REASON: " & $iReason
1167+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnBrowserGotFocus]: GUI: " & $hGUI & " REASON: " & $iReason
11751168 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
11761169 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__BROWSER_GOT_FOCUS )
11771170 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1180,7 +1173,7 @@ Func __NetWebView2_Events__OnBrowserGotFocus($oWebV2M, $hGUI, $iReason)
11801173EndFunc ; ==>__NetWebView2_Events__OnBrowserGotFocus
11811174
11821175Func __NetWebView2_Events__OnBrowserLostFocus($oWebV2M , $hGUI , $iReason )
1183- Local Const $s_Prefix = " [WebViewEvents__OnBrowserLostFocus]: REASON: " & $iReason
1176+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnBrowserLostFocus]: GUI: " & $hGUI & " REASON: " & $iReason
11841177 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
11851178 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__BROWSER_LOST_FOCUS )
11861179 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1189,7 +1182,7 @@ Func __NetWebView2_Events__OnBrowserLostFocus($oWebV2M, $hGUI, $iReason)
11891182EndFunc ; ==>__NetWebView2_Events__OnBrowserLostFocus
11901183
11911184Func __NetWebView2_Events__OnZoomChanged($oWebV2M , $hGUI , $iFactor )
1192- Local Const $s_Prefix = " [WebViewEvents__OnZoomChanged]: FACTOR: " & $iFactor
1185+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnZoomChanged]: GUI: " & $hGUI & " FACTOR: " & $iFactor
11931186 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
11941187 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__ZOOM_CHANGED )
11951188 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1198,7 +1191,7 @@ Func __NetWebView2_Events__OnZoomChanged($oWebV2M, $hGUI, $iFactor)
11981191EndFunc ; ==>__NetWebView2_Events__OnZoomChanged
11991192
12001193Func __NetWebView2_Events__OnURLChanged($oWebV2M , $hGUI , $sURL )
1201- Local Const $s_Prefix = " [WebViewEvents__OnURLChanged]: URL: " & $sURL
1194+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnURLChanged]: GUI: " & $hGUI & " URL: " & $sURL
12021195 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12031196 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__URL_CHANGED )
12041197 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1207,7 +1200,7 @@ Func __NetWebView2_Events__OnURLChanged($oWebV2M, $hGUI, $sURL)
12071200EndFunc ; ==>__NetWebView2_Events__OnURLChanged
12081201
12091202Func __NetWebView2_Events__OnTitleChanged($oWebV2M , $hGUI , $sTITLE )
1210- Local Const $s_Prefix = " [WebViewEvents__OnTitleChanged]: TITLE: " & $sTITLE
1203+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnTitleChanged]: GUI: " & $hGUI & " TITLE: " & $sTITLE
12111204 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12121205 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__TITLE_CHANGED )
12131206 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1216,7 +1209,7 @@ Func __NetWebView2_Events__OnTitleChanged($oWebV2M, $hGUI, $sTITLE)
12161209EndFunc ; ==>__NetWebView2_Events__OnTitleChanged
12171210
12181211Func __NetWebView2_Events__OnNavigationStarting($oWebV2M , $hGUI , $sURL )
1219- Local Const $s_Prefix = " [WebViewEvents__OnNavigationStarting]: URL: " & $sURL
1212+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnNavigationStarting]: GUI: " & $hGUI & " URL: " & $sURL
12201213 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12211214 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__NAV_STARTING )
12221215 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1225,7 +1218,7 @@ Func __NetWebView2_Events__OnNavigationStarting($oWebV2M, $hGUI, $sURL)
12251218EndFunc ; ==>__NetWebView2_Events__OnNavigationStarting
12261219
12271220Func __NetWebView2_Events__OnNavigationCompleted($oWebV2M , $hGUI , $bIsSuccess , $iWebErrorStatus )
1228- Local Const $s_Prefix = " [WebViewEvents__OnNavigationCompleted]: " & ($bIsSuccess ? " SUCCESS" : " ERROR (" & $iWebErrorStatus & " )" )
1221+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnNavigationCompleted]: GUI: " & $hGUI & " " & ($bIsSuccess ? " SUCCESS" : " ERROR (" & $iWebErrorStatus & " )" )
12291222 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12301223 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__NAVIGATION_COMPLETED )
12311224 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1234,23 +1227,23 @@ Func __NetWebView2_Events__OnNavigationCompleted($oWebV2M, $hGUI, $bIsSuccess, $
12341227EndFunc ; ==>__NetWebView2_Events__OnNavigationCompleted
12351228
12361229Func __NetWebView2_Events__OnContextMenuRequested($oWebV2M , $hGUI , $sLink , $iX , $iY , $sSelection )
1237- Local Const $s_Prefix = " [WebViewEvents__OnContextMenuRequested]: LINK: " & $sLink & " X: " & $iX & " Y: " & $iY & " SELECTION: " & $sSelection
1230+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnContextMenuRequested]: GUI: " & $hGUI & " LINK: " & $sLink & " X: " & $iX & " Y: " & $iY & " SELECTION: " & $sSelection
12381231 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12391232 If $_g_sNetWebView2_User_WebViewEvents Then
12401233 Call ($_g_sNetWebView2_User_WebViewEvents & ' OnContextMenuRequested' , $oWebV2M , $hGUI , $sLink , $iX , $iY , $sSelection )
12411234 EndIf
12421235EndFunc ; ==>__NetWebView2_Events__OnContextMenuRequested
12431236
12441237Func __NetWebView2_Events__OnContextMenu($oWebV2M , $hGUI , $sMenuData )
1245- Local Const $s_Prefix = " [WebViewEvents__OnContextMenu]: MENUDATA: " & $sMenuData
1238+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnContextMenu]: GUI: " & $hGUI & " MENUDATA: " & $sMenuData
12461239 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12471240 If $_g_sNetWebView2_User_WebViewEvents Then
12481241 Call ($_g_sNetWebView2_User_WebViewEvents & ' OnContextMenu' , $oWebV2M , $hGUI , $sMenuData )
12491242 EndIf
12501243EndFunc ; ==>__NetWebView2_Events__OnContextMenu
12511244
12521245Func __NetWebView2_Events__OnWebResourceResponseReceived($oWebV2M , $hGUI , $iStatusCode , $sReasonPhrase , $sRequestUrl )
1253- Local Const $s_Prefix = " [WebViewEvents__OnWebResourceResponseReceived ]: HTTP : " & $iStatusCode & " (" & $sReasonPhrase & " ) URL: " & $sRequestUrl
1246+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnWebResourceResponseReceived ]: GUI: " & $hGUI & " HTTPStatusCode : " & $iStatusCode & " (" & $sReasonPhrase & " ) URL: " & $sRequestUrl
12541247 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12551248 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__RESPONSE_RECEIVED )
12561249 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1259,7 +1252,7 @@ Func __NetWebView2_Events__OnWebResourceResponseReceived($oWebV2M, $hGUI, $iStat
12591252EndFunc ; ==>__NetWebView2_Events__OnWebResourceResponseReceived
12601253
12611254Func __NetWebView2_Events__OnDownloadStarting($oWebV2M , $hGUI , $sURL , $sDefaultPath )
1262- Local Const $s_Prefix = " [WebViewEvents__OnDownloadStarting]: URL: " & $sURL & " DEFAULT_PATH: " & $sDefaultPath
1255+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnDownloadStarting]: GUI: " & $hGUI & " URL: " & $sURL & " DEFAULT_PATH: " & $sDefaultPath
12631256 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12641257 __NetWebView2_LastMessageReceived($NETWEBVIEW2_MESSAGE__DOWNLOAD_STARTING )
12651258 If $_g_sNetWebView2_User_WebViewEvents Then
@@ -1268,7 +1261,7 @@ Func __NetWebView2_Events__OnDownloadStarting($oWebV2M, $hGUI, $sURL, $sDefaultP
12681261EndFunc ; ==>__NetWebView2_Events__OnDownloadStarting
12691262
12701263Func __NetWebView2_Events__OnDownloadStateChanged($oWebV2M , $hGUI , $sState , $sURL , $iTotal_Bytes , $iReceived_Bytes )
1271- Local Const $s_Prefix = " [WebViewEvents__OnDownloadStateChanged]: State: " & $sState & " URL: " & $sURL & " Total_Bytes: " & $iTotal_Bytes & " Received_Bytes: " & $iReceived_Bytes
1264+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnDownloadStateChanged]: GUI: " & $hGUI & " State: " & $sState & " URL: " & $sURL & " Total_Bytes: " & $iTotal_Bytes & " Received_Bytes: " & $iReceived_Bytes
12721265 Local $iPercent = 0
12731266 If $iTotal_Bytes > 0 Then $iPercent = Round (($iReceived_Bytes / $iTotal_Bytes ) * 100 )
12741267
@@ -1294,7 +1287,7 @@ Func __NetWebView2_Events__OnDownloadStateChanged($oWebV2M, $hGUI, $sState, $sUR
12941287EndFunc ; ==>__NetWebView2_Events__OnDownloadStateChanged
12951288
12961289Func __NetWebView2_Events__OnAcceleratorKeyPressed($oWebV2M , $hGUI , $oArgs )
1297- Local Const $s_Prefix = " [WebViewEvents__OnAcceleratorKeyPressed]: ARGS: OBJECT"
1290+ Local Const $s_Prefix = " [NetWebView2Lib:EVENT: OnAcceleratorKeyPressed]: GUI: " & $hGUI & " ARGS: OBJECT"
12981291 __NetWebView2_Log(@ScriptLineNumber , (StringLen ($s_Prefix ) > 150 ? StringLeft ($s_Prefix , 150 ) & " ..." : $s_Prefix ), 1 )
12991292 If $_g_sNetWebView2_User_WebViewEvents Then
13001293 Call ($_g_sNetWebView2_User_WebViewEvents & ' OnAcceleratorKeyPressed' , $oWebV2M , $hGUI , $oArgs )
0 commit comments