Conversation
018-BasicFramesDemo.au3
mlipok
approved these changes
Feb 24, 2026
Contributor
mlipok
left a comment
There was a problem hiding this comment.
Ok It works.
Maybe we find better way later
| $aFrames[$IDX_Frame][$FRAME_URL] = $oFrame.Source | ||
| $aFrames[$IDX_Frame][$FRAME_DESTROYED] = $oFrame.IsDestroyed() | ||
| $aFrames[$IDX_Frame][$FRAME_HTML] = $oWebV2M.GetFrameHtmlSource($IDX_Frame) | ||
| $aFrames[$IDX_Frame][$FRAME_HTML] = Fire_And_Wait($oWebV2M.GetFrameHtmlSource($IDX_Frame), 5000) |
Contributor
There was a problem hiding this comment.
I do not like the Fire_And_Wait() solution
I think I need to find another solution.
Owner
Author
There was a problem hiding this comment.
to move the logic (WaitAndGetResult) to the C# side and handle the asynchronous delay internally.?
Contributor
There was a problem hiding this comment.
No. Lets stay with what we have.
Owner
Author
There was a problem hiding this comment.
alternatively
with using the new frame method
⚡ExecuteScriptWithResult
Type: string (Synchronous/Blocking)
Description: Executes JavaScript in the frame and waits for the result (Thread-Safe).
object.ExecuteScriptWithResult(Script As String)
to fire "document.documentElement.outerHTML"
; #FUNCTION# ====================================================================================================================
; Name...........: _WebView2_GetFrameHtmlSource
; Description....: Synchronously retrieves the full HTML source of a frame and unescapes it.
; Syntax.........: _WebView2_GetFrameHtmlSource($oFrame)
; Parameters.....: $oFrame - The WebView2Frame object.
; Return values..: Success - Clean HTML string.
; Failure - Sets @error and returns empty string.
; ===============================================================================================================================
Func _WebView2_GetFrameHtmlSource($oFrame)
If Not IsObj($oFrame) Then Return SetError(1, 0, "$oFrame is not a valid object")
; Execute script synchronously
Local $sRaw = $oFrame.ExecuteScriptWithResult("document.documentElement.outerHTML")
; Basic validation
If $sRaw = "null" Or $sRaw = "" Then Return ""
If StringLeft($sRaw, 6) = "ERROR:" Then Return SetError(2, 0, $sRaw)
; Pre-process: Strip the mandatory JSON quotes BEFORE unescaping.
; This prevents the C# Parser from "double-wrapping" the string.
If StringLeft($sRaw, 1) = '"' And StringRight($sRaw, 1) = '"' Then
$sRaw = StringMid($sRaw, 2, StringLen($sRaw) - 2)
EndIf
; Initialize Parser from the library
Local $oJson = _NetJson_CreateParser()
If @error Then Return SetError(3, 0, "Failed to create JsonParser")
; Use the Parser's UnescapeString to handle all escapes (\uXXXX, \n, \", etc.)
Local $sClean = $oJson.UnescapeString($sRaw)
Return $sClean
EndFunc ;==>_WebView2_GetFrameHtmlSource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
018-BasicFramesDemo.au3
Important
Thanks for your effort and interest 💛 in improving the project. It's very appreciated.
Description
adjust the 018-BasicFramesDemo.au3 example
🔗 Linked GitHub Issues
#91
Closes #<number>
📋 What is the current behavior?
🚀 What is the new behavior?
Type of changes
Breaking changes 🔥
How and where was this tested?
🖥️ Describe where you tested your changes
System:
Context:
NetJson.ParserNetWebView2.Manager - WebView2NetWebView2.Manager - Bridge🔬 Describe how you tested your changes
Checklist
Additional context
Screenshots
Note to reviewers