@@ -151,7 +151,7 @@ Func _NetWebView2_CreateManager($sUserAgent = "", $s_fnEventPrefix = "", $s_AddB
151151 If @error Then
152152 $ERR = @error
153153 $EXT = @extended
154- $MSG = " Manager Creation Error " & " #SLN=" & @ScriptLineNumber
154+ $MSG = " Manager Creation Error " & " #SLN=" & @ScriptLineNumber
155155 Else
156156 ; Enable/Disable diagnostic logging
157157 ; When enabled, the console will show entries like: +++[NetWebView2Lib][HANDLE:0x...][HH:mm:ss.fff] Message
@@ -663,7 +663,7 @@ Func _NetWebView2_Navigate($oWebV2M, $s_URL, $iWaitMessage = $NETWEBVIEW2_MESSAG
663663 ElseIf $iWaitMessage < $NETWEBVIEW2_MESSAGE__INIT_READY Or $iWaitMessage > $NETWEBVIEW2_MESSAGE__TITLE_CHANGED Then
664664 ; Parameter Validation - higher messsages are not for NAVIGATION thus not checking in _NetWebView2_LoadWait()
665665 $ERR = 2
666- $MSG = " ERROR: $iWaitMessage not valid" & " #SLN=" & @ScriptLineNumber
666+ $MSG = " ERROR: $iWaitMessage not valid" & " #SLN=" & @ScriptLineNumber
667667 Else
668668 ; Execute Navigation
669669 ; The Local Error Handler catches potential "Disposed Object" crashes here
@@ -815,9 +815,9 @@ Func _NetWebView2_ExportPageData($oWebV2M, $iFormat, $sFilePath = "")
815815 $RET = $oWebV2M .ExportPageData($iFormat , $sFilePath )
816816 If StringLeft ($RET , 6 ) = " ERROR:" Then
817817 $ERR = 1
818- $MSG = " RESULT:" & $RET & " #SLN=" & @ScriptLineNumber
818+ $MSG = " RESULT:" & $RET & " #SLN=" & @ScriptLineNumber
819819 Else
820- $MSG = " RESULT: SUCCESS" & " #SLN=" & @ScriptLineNumber
820+ $MSG = " RESULT: SUCCESS" & " #SLN=" & @ScriptLineNumber
821821 EndIf
822822
823823 __NetWebView2_Log(@ScriptLineNumber , $s_Prefix & $MSG , 1 , $ERR , $EXT )
@@ -1516,9 +1516,11 @@ Func __NetWebView2_LastMessage_KEEPER($oWebV2M, $iMessage = Default, $iError = @
15161516 If $iMessage = Default Then ; function acts as GET
15171517 $RET = $mLastMessegKeeper [$sKey ]
15181518 Else
1519- __NetWebView2_LastMessage__INTERNALL($mLastMessegKeeper , $sKey , $iMessage , @error , @extended )
1519+ ; ~ __NetWebView2_LastMessage__INTERNALL($mLastMessegKeeper, $sKey, $iMessage, @error, @extended)
15201520
1521+ #TODO $sKey support int __NetWebView2_LastMessage_onReceived - multi instances
15211522 __NetWebView2_LastMessage_onReceived($oWebV2M , $iMessage )
1523+ #TODO $sKey support int __NetWebView2_LastMessage_Navigation - multi instances
15221524 __NetWebView2_LastMessage_Navigation($oWebV2M , $iMessage )
15231525 EndIf
15241526
@@ -1581,33 +1583,38 @@ Func __NetWebView2_LastMessage_Navigation($oWebV2M, $iMessage = Default, $iError
15811583EndFunc ; ==>__NetWebView2_LastMessage_Navigation
15821584
15831585Func __NetWebView2_LastMessage__INTERNALL(ByRef $mStatus , $sKey , $iMessage = Default , $iError = @error , $iExtended = @extended )
1584- Local Const $s_Prefix = " >>>[__NetWebView2_LastMessage__INTERNALL]:"
1586+ Local Const $s_Prefix = " >>>[__NetWebView2_LastMessage__INTERNALL]: Key: " & $sKey & " Message: " & $iMessage
15851587 Local $ERR = 0 , $EXT = 0 , $RET = False , $MSG = " " ; predefined endpoint results
1588+ ; ~ $sKey = StringRegExpReplace($sKey, "(?i)(.*?)(\d[\dxa-f]+)(.*)", "$2") ; example: [HANDLE:0x0000000000240C00] >> 0x0000000000240C00
1589+ ; ~ $sKey = "hwnd" & StringRegExpReplace($sKey, "(?i)(.*?\dx)([\da-f]+)(.*)", "$2") ; example: [HANDLE:0x0000000000240C00] >> 0000000000240C00
15861590
15871591 If $iError Then ; If an error occurred while retrieving the Handle (e.g. Object already closed)
15881592 #TODO REFACTOR: this check should be out of this function
15891593 $ERR = 1
15901594 $RET = $NETWEBVIEW2_MESSAGE__NONE
1595+ $MSG = " OUTER ERROR" & " #SLN=" & @ScriptLineNumber
15911596 ElseIf $sKey = " 0" Or $sKey = " " Then ; If the handle is invalid
15921597 $ERR = 2
15931598 $RET = $NETWEBVIEW2_MESSAGE__NONE
1594- ElseIf $iMessage = Default Then ; --- GET MODE (Called from LoadWait) ---
1595- If Not MapExists($mStatus , $sKey ) Then
1596- $ERR = 3
1597- $RET = $NETWEBVIEW2_MESSAGE__NONE
1598- Else
1599- $RET = $mStatus [$sKey ]
1600- EndIf
1599+ $MSG = " Invalid KEY value" & " #SLN=" & @ScriptLineNumber
1600+ ElseIf ($iMessage = - 1 Or $iMessage = Default ) And Not MapExists($mStatus , $sKey ) Then ; for RESET and GET key must exist
1601+ $ERR = 3
1602+ $RET = $NETWEBVIEW2_MESSAGE__NONE
1603+ $MSG = " KEY=" & $sKey & " (BrowserWindowHandle) NOT FOUND" & " #SLN=" & @ScriptLineNumber
16011604 ElseIf $iMessage = - 1 Then ; If -1, performs cleanup ; Special case: -1 for memory cleanup when the instance is closed
1602- If MapExists( $mStatus , $sKey ) Then MapRemove($mStatus , $sKey )
1605+ MapRemove($mStatus , $sKey )
16031606 $RET = $NETWEBVIEW2_MESSAGE__NONE
1607+ ElseIf $iMessage = Default Then ; --- GET MODE (Called from LoadWait) ---
1608+ $RET = $mStatus [$sKey ]
16041609 Else ; Update the status for this specific Handle
16051610 $mStatus [$sKey ] = $iMessage
16061611 $RET = $iMessage
16071612 EndIf
16081613
1609- $ERR = $iError ; prevent @error changes
1610- $EXT = $iExtended ; prevent @extended changes
1614+ If Not $ERR Then
1615+ $ERR = $iError ; prevent @error changes
1616+ $EXT = $iExtended ; prevent @extended changes
1617+ EndIf
16111618
16121619 __NetWebView2_Log(@ScriptLineNumber , $s_Prefix & $MSG , 1 , $ERR , $EXT )
16131620 Return SetError ($ERR , $EXT , $RET )
0 commit comments