-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
Code:
WV.AddSCriptToExecuteOnDocumentCreated New_c.FSO.ReadTextContent("MyHelpers.js", False, CP_UTF8)
With reference to your above one line of code in post no. 277, I have the following query.
--
When trying to add a .js file (say 'simple.js') in the above manner, I found that it was working only if there are no jQuery calls in my 'simple.js' file. It took me some considerable amount of time to find out that jQuery calls were the problem. Am I doing a mistake? Or, is it that I indeed cannot use jQuery calls in the js strings added via WV.AddSCriptToExecuteOnDocumentCreated? If I can use jquery, then how to achieve that? I do have proper references to jquery.js in my 'simple.html' file. 'Simple.html' does work correctly if I include 'simple.js' directly in it and I "WV.Navigate" to 'simple.html' directly in my VB application.
--
Note: I did take time to search each of the pages in this thread for 'jQuery'. But, I could not find any post discussing about it. I thought may be it is written in some post by dear Olaf that only 'Pure JS' can be used. So, right now I searched on "Pure JS" in this thread but could not find any post mentioning the same. Well, may be it is mentioned in a different way by dear Olaf. I don't know.
In the above context, I will be truly grateful if someone can let me know what is the best way to find out whether a particular matter has been already discussed in this thread (in this thread "alone"). At present, I am clicking each numbered page link at the top of this thread and searching on a particular term (say 'jQuery'). Is there a faster way of searching so that if I search on 'jQuery', I immediately get to see all the pages (in this thread alone) in which it appears or 'no results' if it is not present in any of the pages (in this thread). That will help me a lot. Really. I did try the 'Advanced search but it does not seem to zero-in on the specific post(s). For e.g. for a 'Keyword:' of FSO.ReadTextContent and 'User Name:' of Schmidt, the results do not show me the exact post (277) in which the Keyword has been used. May be I am searching wrongly, I don't know. Sometimes, I do miss the obvious and focus elsewhere. Probably that is the case here also. So, kindly help me out.
I take this opportunity to thank you once again, Olaf, for helping us all out, to the best extent you can, always, even amidst your hectic schedules. I personally know how arduous it is (to give such help, regularly) but at the same time how joyful it is too (ultimately) since it results in immense benefit to the world society. God Bless you. God Bless ALL.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
...When trying to add a .js file (say 'simple.js') in the above manner,
I found that it was working only if there are no jQuery calls in my 'simple.js' file.
With the now available browser-built-in selector-functions, there's rarely a need for jQuery anymore...
That said - jQuery is an external js-lib - and therefore needs to be (pre)loaded as well -
ideally before you add your own js-scripts.
You can ensure that either in the HTML (via the usual <script>-tags) -
or use AddScriptOnDocumentCreate as well for jQuery...
Below is some Demo-Code:
(which downloads jQuery dynamically "as String" via a http51-helperfunction - but once downloaded via wgetJQ(),
you can of course put the retrieved string into your own local js-file - and load it from there in future-runs)...
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True
Set WV = New_c.WebView2(hWnd)
WV.AddScriptToExecuteOnDocumentCreated wgetJQ("https://code.jquery.com/jquery-3.6.4.js")
WV.AddScriptToExecuteOnDocumentCreated "function setColor_SelectorBased(sel,clr){" & _
" $(sel).each(function(){$(this).css('background-color',clr)})" & _
"}"
WV.NavigateToString "<p>first Para</p><p>second Para</p><p>last Para</p>"
WV.jsRun "setColor_SelectorBased", "p:first, p:last", "magenta"
End Sub
Public Function wgetJQ(URL) As String
With CreateObject("WinHttp.WinHttpRequest.5.1")
.open "GET", URL: .send: wgetJQ = .responseText
'hot-fixes for two edge/chromium-related bugs in the current jQuery-release
wgetJQ = Replace(wgetJQ, "el = document", "el = window.document")
wgetJQ = Replace(wgetJQ, "documentElement.getRootNode", "documentElement && documentElement.getRootNode")
End With
End Function
If all works well, the first and the last of the 3 <p>-Tags should be colored magenta.
Edit: Seems, that the WebView2-method: AddScriptToExecuteOnDocumentCreated -
does not live up to its "second symbolname-part" anymore...
(hope, they are fixing this soon)...
In the interim, you can enclose all such added scripts with your own js-event-listener:
(example is based on the working one above, but now not even the "jQuery-hotfixes" are needed anymore,
when the script-adding is delayed until the document "is sitting properly in the DOM")
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True
Set WV = New_c.WebView2(hWnd)
With New_c.StringBuilder
.AddNL wget("https://code.jquery.com/jquery-3.6.4.js")
.AddNL "$('p:first, p:last').each(function(){$(this).css('background-color','magenta')})"
WV.AddScriptToExecuteOnDocumentCreated "window.addEventListener('load',(e)=>{" & .ToString & "})"
End With
WV.NavigateToString "<p>first Para</p><p>second Para</p><p>last Para</p>"
End Sub
Public Function wget(URL) As String 'generic text-retrieval "by URL"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.open "GET", URL: .send: wget = .responseText
End With
End Function
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Why not iterate over them from the inside of a little js-function?
You can pass String-Parameters into such functions just fine from the VB-Side...
(like e.g. QuerySelector-StringPatterns, or just "plain IDs", along with e.g. Color-Strings).
In short, complex DOM-operations remain "in generic, clever parametrized js-helpers" -
and then these "nice trigger-parameters" could (should) be passed from the VB-side.
Olaf
Sorry to ask again, but can you please show me an example?
My problem is that I don't know how to access the hotspots that the function returns.
I have tried this:
Dim hotspots
hotspots = WV.jsRun("window._grid_ensureHotSpotIds")
Debug.Print UBound(hotspots) 'here it errors out saying "Type mismatch" (obviously it's not an array. It's empty)
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
With the now available browser-built-in selector-functions, there's rarely a need for jQuery anymore...
... .. .
Edit: Seems, that the WebView2-method: AddScriptToExecute
OnDocumentCreated -
does not live up to its "
second symbolname-part" anymore...
(hope, they are fixing this soon)...
In the interim, you can enclose all such added scripts with your
own js-event-listener:
(example is based on the working one above, but now not even the "jQuery-hotfixes" are needed anymore,
when the script-adding is
delayed until the document "is sitting properly in the DOM")
Olaf
Dear Olaf,
Thanks a TON for both the initial demo-code and its Edit later on.
The starting info mentioned by you in your "Edit" portion was exactly the cause of my problem (reported earlier) and not jQuery.
Actually, after posting my earlier message, as I was exploring further, I realised that even some "pure js" statements were not working (much like the jQuery statements) if they were lying globally (instead of inside some functions) in my ".js" file. So, what I did finally was to place all of those non-working lines of code inside the following DOMContentLoaded "listener" function
Code:
Document.addEventListener('DOMContentLoaded', function () {
... .. .
}
Then, everything worked "perfectly" with absolutely no hitch. That made me come to the realisation that the DOM elements were not visible to the globally lying lines of code if my whole js file is added as a string via 'AddScriptToExecuteOnDocumentCreated'. Based on that realisation, the conclusion to which I reached was that my understanding of what "AddScriptToExecuteOnDocumentCreated" would do was incorrect.
I came back here to share my conclusion and asking you whether my understanding is correct. That is when I saw your Edit wherein you have remarked that the 2nd part of "AddScriptToExecuteOnDocumentCreated" is a sort of bug itself. Thanks Olaf.
And, it was very nice to see the following 'yet another' cute compact one-liner :) from you to overcome the seeming bug in "AddScriptToExecuteOnDocumentCreated".
Code:
WV.AddScriptToExecuteOnDocumentCreated "window.addEventListener('load',(e)=>{" & .ToString & "})"
So, what I did (as a very quick test) was to check out your above one-liner straightaway in my VB application [of course after replacing the ".ToString" in your one-liner with "New_c.FSO.ReadTextContent("MyFullFile.js", False, CP_UTF8)"]. But, it looked like that the above resulted in the existing function [Document.addEventListener('DOMContentLoaded', function ()] in my ".js" file to not to take effect. I remember reading somewhere in the net today (and some days back too) that if we decide to use more than one OnLoad listener, then these listerners should be added to a list of listeners. OR else, sometimes, one of the listeners would replace the other listeners. Perhaps that is what is happening when I use your one-liner. I don't know that for sure now. Because, as of now, I just did a very quick test only. Thanks once again for your cute one-liner. I just loved it. When time permits, I will try to learn what to do in my ".js", in order to use your one-liner.
By the way, when you say "With the now available browser-built-in selector-functions, ... .. .", I think you mean the querySelector and querySelectorAll functions. If so, then, yes, after reading your posts mentioning about them, I do have started using them and are very convenient. Will try to slowly move over to querySelectors completely. Thanks a TON.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
...it looked like that the above resulted in the existing function
[Document.addEventListener('DOMContentLoaded', function ()] in my ".js" file
to not to take effect. ...
If it is enclosed by "my" outer "onload"-callback-snippet, then "your" (inner) event-listener-installation comes "too late" ...
since you prepare your listening, when the document-load-event has already happened (was already catched by me) -
and therefore installing the Listener "at that point in time" will never trigger the code in "your" inner callback-function-block...
Easy solution would be, to remove your own listener-installation from your js-source-file
(also in preparation for a potentially upcoming bugfix by MS for the AddScriptToExecuteOnDocumentCreated-call).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Sorry to ask again, but can you please show me an example?
My problem is that I don't know how to access the hotspots that the function returns.
I have tried this:
Dim hotspots
hotspots = WV.jsRun("window._grid_ensureHotSpotIds")
Debug.Print UBound(hotspots) 'here it errors out saying "Type mismatch" (obviously it's not an array. It's empty)
You will have to check in your js-source, whether the window._grid_ensureHotSpotIds function,
returns something at all...
And if it does, then gather these results in your own array -
and then return this array as a serialized JSON-string via:
return JSON.stringify(myHotspotArray)
At the vb6-side you can then easily convert that returned JSON-string into a cCollection:
Dim oHotSpots As cCollection
Set oHotSpots = New_c.JSONDecodeToCollection(WV.jsRun("window._grid_ensureHotSpotIds"))
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
... .. .
Easy solution would be, to remove your own listener-installation from your js-source-file
(also in preparation for a potentially upcoming bugfix by MS for the AddScriptToExecuteOnDocumentCreated-call).
Olaf
What care and concern from you in your support!!! I am quite enjoying it, working with RC6 and also receiving your wonderful loving support. Have missed a LOT of both, I am sure, by not getting time to start using 'RC' very many years back itself, though I always knew inside my heart that 'RC' was such a treasure of a contribution!
Well, the very first thing I tried was that only - removing my own 'DOMContentLoaded' listener line. But, it did not work. That quite surprised me, like anything! Because, I was almost certain that that would be enough. So, I started examining my code carefully and found out that I had left a piece of helper-function code still in my VB app itself. I commented out that line and added that function also in my 'MyFullFile.js' and everything worked like a charm!
Your tip in post 277 that all helper functions shall be called from a single .js file made me think why not call my whole .js file itself from inside VB. Now that it is possible, it is (and will continue to be) of great help to me, going forward, I believe. Once again thanks for your OnLoad listener one-liner! Superb!
Ever remaining in awe of both your work and your heart.
Kindest Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
My problem is that stringify does not work. hotspots.count is 196, but the line "alert('after stringify');" is not fired in the code below:
Code:
HTMLElement.prototype._grid_ensureHotSpotIds = function(selector)
{
let hotSpots = [];
if (selector != null)
{
var splitSelector = selector.split(',');
//Some websites need a selector that's too complex to make just in one step. So we need to split the selector on commas and do querySelectors that will chain the results.
splitSelector.forEach(singleSelector =>
{
if (hotSpots != null)
{
let hotSpotsFound = this.querySelectorAll(singleSelector);
if (hotSpotsFound != null)
{
hotSpots = hotSpots.concat(Array.from(hotSpotsFound));
}
else
{
//alert('hotspots is null in splitselector');
}
}
});
}
else
{
hotSpots = this.querySelectorAll(hotSpotSelector);
}
//alert("Found " + hotSpots.length + " hotspots."); // Alert showing the number of hotspots found
for (var hotSpot of hotSpots)
{
hotSpot._grid_ensureId();
}
alert('before stringify');
let hotSpotsString = JSON.stringify(hotSpots); // Convert the hotspots array to a JSON string
alert('after stringify');
alert("Hotspots: " + hotSpotsString); // Alert showing the hotspots as a string
return hotSpotsString; // Return the hotspots array as a JSON string
};
I guess it could be due to members of such a hotspot.
I have uploaded the prototype of "element" which I try to stringify:
https://drive.google.com/file/d/1XPd...usp=share_link
Edit: I know now that in C# the hotspots are handled like this:
C# code:
Code:
protected virtual Task<HtmlElementReference> GetStartElementAsync(HtmlElementReference startElement, CursorDirection direction)
{
return Task.FromResult<HtmlElementReference>(startElement);
}
protected async Task<HtmlElementReference> HandleFindElementResultAsync(ElementCursorBase.FindElementResult result, IWebBrowserFrame currentFrame, string getNodesFunc, int? nodeType, CursorDirection direction)
{
HtmlElementReference htmlElementReference;
HtmlElementReference elementReferenceAsync;
CursorDirection cursorDirection;
string str;
if (result != null)
{
switch (result.ResultType)
{
case ElementCursorBase.FindElementResultType.Element:
{
htmlElementReference = new HtmlElementReference(currentFrame.Identifier, result.Element);
return htmlElementReference;
}
case ElementCursorBase.FindElementResultType.IterateUpIntoParent:
{
HtmlElementReference elementReferenceAsync1 = await WebBrowserExtensionMethods.GetElementReferenceAsync(currentFrame.Parent, String.Format("document.querySelector('[data-grid-frame-identifier=\"{0}\"]')._grid_ensureId()", currentFrame.Identifier));
cursorDirection = direction;
if (cursorDirection == CursorDirection.Backward || cursorDirection == CursorDirection.BackwardToHeading)
{
getNodesFunc = "_grid_getPreviousNodes";
}
htmlElementReference = await this.FindElementAsync(elementReferenceAsync1, getNodesFunc, nodeType, false, direction);
return htmlElementReference;
}
case ElementCursorBase.FindElementResultType.IterateDownIntoFrame:
{
using (IWebBrowserFrame frame = this._webBrowser.GetFrame(Convert.ToUInt64(result.Element)))
{
if (frame != null)
{
cursorDirection = direction;
switch (cursorDirection)
{
case CursorDirection.Forwards:
case CursorDirection.ForwardsToHeading:
{
str = "document.body._grid_ensureId()";
break;
}
case CursorDirection.Backward:
case CursorDirection.BackwardToHeading:
{
str = "document.body._grid_getLastElement()._grid_ensureId()";
getNodesFunc = "_grid_getSelfAndPreviousNodes";
break;
}
default:
{
throw new InvalidOperationException();
}
}
elementReferenceAsync = await WebBrowserExtensionMethods.GetElementReferenceAsync(frame, str);
}
else
{
htmlElementReference = null;
return htmlElementReference;
}
}
frame = null;
htmlElementReference = await this.FindElementAsync(elementReferenceAsync, getNodesFunc, nodeType, true, direction);
return htmlElementReference;
}
}
throw new InvalidOperationException();
}
else
{
htmlElementReference = null;
}
return htmlElementReference;
throw new InvalidOperationException();
}
Would there be any way to do the same with your browser?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
To be more specific: Can VB6-WebView2 handle async tasks like shown in the C# code?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
ps: cairo_sqlite.dll is missing a version number.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I have tried to disable the context command, but I think there are no commandline switches available for these settings:
webView.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false;
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
How could I do this with VB6-WebView2?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
To be more specific: Can VB6-WebView2 handle async tasks like shown in the C# code?
I'd ask the developer who has programmed the C# interaction (with CEF),
to write a similar js-function for you...
WebView2 is using chromium as well, but as said, the DOM-interfaces are not exposed to the VB/COM-side here.
Therefore you have to use "preloaded js-functions" to interact with the Browser-DOM "on the inside" of WV2 -
and communicate with the outside via JSON-strings.
Such a C#->js-v8 porting should not be that hard for the developer, who originally wrote the C#-stuff.
All I can do here from my end, is to show you the "principle".
Code:
Option Explicit
Private WithEvents WV As cWebView2, Elements As cCollection
Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)
With New_c.StringBuilder 'js-helpers
.AddNL "function getElements(sExpr){"
.AddNL " var resArr = []"
.AddNL " for (var e of document.querySelectorAll(sExpr).values()){"
.AddNL " resArr.push({tag:e.tagName, id:e.id, val:e.value, name:e.name, href:e.href})"
.AddNL " }"
.AddNL " return JSON.stringify(resArr)"
.AddNL "}"
.AddNL "function setElementBackgroundById(id, color){"
.AddNL " document.querySelector('#'+id).style.background = color"
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
With New_c.StringBuilder 'two anchors and two buttons as test-HTML-content
.AddNL "<a id='a1' href='#foo'>LinkFoo</a><br>"
.AddNL "<input id='b1' type='button' value='button 1'><br>"
.AddNL "<a id='a2' href='#bar'>LinkBar</a><br>"
.AddNL "<input id='b2' type='button' value='button 2'><br>"
WV.NavigateToString .ToString
End With
'retrieve a few elements "by selector-expression"
Set Elements = New_c.JSONDecodeToCollection(WV.jsRun("getElements", "a, input"))
Dim Elmt As cCollection 'the enumerated Elements themselves are (again) of type cCollection - but hold a JSON-Object instead of a JSON-array
For Each Elmt In Elements 'iteration over the gathered Element-Objects in the JSON-Array: Elements
Debug.Print Elmt.SerializeToJSONString 'just to show, which properties are contained "per element"
Select Case UCase$(Elmt("tag")) 'first Property-access on an Element (here the "tag"-Property)
Case "A": WV.jsRun "setElementBackgroundById", Elmt("id"), "#f00"
Case "INPUT": WV.jsRun "setElementBackgroundById", Elmt("id"), "#0f0"
End Select
Next
End Sub
... but the adaption of the above shown principle (to your concrete problem), really is your part.
And as for cairo_sqlite.dll versions:
- New_c.Cairo.Version ... will hand out the cairo-version
- New_c.Connection.Version ... will hand out the SQLite-version
...and if you put a question-mark before those expression, you can print the results directly in your immediate-window
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
I have tried to disable the context command, but I think there are no commandline switches available for these settings:
webView.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false;
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
How could I do this with VB6-WebView2?
The blue marked boolean Properties are exposed on cWebView2
(as the <F2>reachable VBIDE-ObjectBrowser would show you, or alternatively intellisense, when you type a . behind WV).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Thank you. I access it from outside in an installer to see if I need to deploy a new version to my users.
There are only a few files that don't provide a version number, and yours were some of them.
I will work around it.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The JS operations are really lengthy.
Would it somehow be possible to make them async and yet return values?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Would it somehow be possible to make them async ...
Sure... (you're still not familiar with the WV-interface, which you can study in the ObjectExplorer)
MyToken = WV.jsRunAsync("MyJsFunctionName", MyInputParams, ...)
Quote:
Originally Posted by
tmighty2
...and yet return values?
Private Sub WV_JSAsyncResult(Result As Variant, ByVal Token As Currency, ByVal ErrString As String)
' If Token = MyToken Then ...
End Sub
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hello Olaf,
WebView2 has Stop method, is there a reason why your cWebView2 doesn't have it? Can you add it to the interface?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Bob17
WebView2 has Stop method, is there a reason why your cWebView2 doesn't have it? Can you add it to the interface?
WV.jsRun "stop" 'should work
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
-
1 Attachment(s)
Re: VB6 WebView2-Binding (Edge-Chromium)
I am showing an email in the form of an xml string in the browser.
Even though the encoding is declared as utf8 and also saved as such, I get strange Umlauts.
What am I doing wrong?
Code:
Public Sub ShowMail(ByVal uXml As String)
Set WV = New_c.WebView2 'create the instance
If WV.BindTo(Me.picWV.hwnd, , , , "--autoplay-policy=no-user-gesture-required") = 0 Then
modLog.WriteLog "#error initilializing browser!"
MsgBox "couldn't initialize WebView-Binding": Exit Sub
End If
WV.AreBrowserAcceleratorKeysEnabled = False
WV.AreDefaultContextMenusEnabled = False
Dim HtmlFile As String
HtmlFile = New_c.fso.GetLocalAppDataPath & "\temp.html"
New_c.fso.WriteTextContent HtmlFile, uXml, True
WV.Navigate HtmlFile
Code:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<mime_message>
<header>
<mime-version>1.0</mime-version>
<date>Fri, 26 Mar 2021 20:38:23 +0100</date>
<message-id> <95B4AC75D4DC194DA3865C264BC6885877F3BB89@xxxxx> </message-id>
<content-type boundary="------------010803010009050608040505"> multipart/alternative </content-type>
<x-priority>3 (Normal)</x-priority>
<from>
<address>
<addr>[email protected]</addr>
<name>xxxxxx</name>
</address>
</from>
<ckx-bounce-address>[email protected]</ckx-bounce-address>
<to>
<address>
<addr>[email protected]</addr>
<name/>
</address>
</to>
<subject>Fwd: AW: </subject>
</header>
<body>
<subpart>
<mime_message>
<header>
<content-type charset="utf-8"> text/plain </content-type>
<content-transfer-encoding>7bit</content-transfer-encoding>
</header>
<body> </body>
</mime_message>
</subpart>
<subpart>
<mime_message>
<header>
<content-type charset="utf-8"> text/html </content-type>
<content-transfer-encoding>quoted-printable</content-transfer-encoding>
</header>
<body>
<![CDATA[ <hr style=3D"color:#62B3FF"><div style=3D"background-color: #DDDDDD; font-s= ize:10pt"><b>Von: </b><a href=3D"mailto:[email protected]">"Anne Willeke= " <[email protected]></a></br><b>Datum: </b>26.03.2021 13:02:16</br><b>A= n: </b><a href=3D"mailto:[email protected]">Johannes xxxxx</a></br><b>B= etreff: </b>Fwd: AW: </div></br><html xmlns:v=3D"urn:schemas-microsoft-com:= vml" xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sch= emas-microsoft-com:office:word" xmlns:m=3D"http://schemas.microsoft.com/off= ice/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40"> <head><META http-equiv=3D"Content-Type" content=3D"text/html;charset=3Dutf-= 8"> <meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} span.E-MailFormatvorlage18 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:windowtext;} =2EMsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3D"DE" link=3D"#0563C1" vlink=3D"#954F72" style=3D"word-wrap:bre= ak-word"> <div class=3D"WordSection1"> <p class=3D"MsoNormal"><span style=3D"mso-fareast-language:EN-US">Ah, jetzt= habe ich es verstanden, den Fragebogen kannst du auch n=C3=A4chste Woche s= chicken. Klar.<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"mso-fareast-language:EN-US">Sch=C3=B6= nes Wochenende!<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"mso-fareast-language:EN-US"><o:p>&nbs= p;</o:p></span></p> <div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm = 0cm 0cm"> <p class=3D"MsoNormal"><b>Von:</b> Johannes xxxxx <[email protected]= > <br> <b>Gesendet:</b> Freitag, 26. M=C3=A4rz 2021 09:40<br> <b>An:</b> Anne Willeke <[email protected]>; [email protected]<= br> <b>Betreff:</b> <o:p></o:p></p> </div> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> </body> </html> ]]>
</body>
</mime_message>
</subpart>
</body>
</mime_message>
Attachment 187395
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The "scrambling" has already happened in this case
(meaning that the passed param uXML already contains "mangled" string-data).
Please check, where (and how) this uXML-param was retrieved (and then passed) -
and whether the proper decoding took place whilst filling it elsewhere.
It might also be, that the xml-header-string (as shown below, for UTF8-mode) -
points to a code-page, entirely different from UTF8... XML allows that...
(in which case, you shouldn't write it out as UTF8 via New_c.FSO.WriteTextContent).
The example code below shows, that when uXML is filled with proper Unicode,
the WebView2 can show Unicode-XML (in this case with a few german Umlauts), just fine.
Code:
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)
Dim uXml$: uXml = "<?xml version='1.0' encoding='UTF-8'?>" & vbCrLf & _
"<root><foo>" & ChrW(228) & ChrW(246) & ChrW(252) & _
"</foo><bar>" & ChrW(223) & ChrW(8364) & ChrW(248) & "</bar></root>"
Const FileName = "c:\temp\simple.xml"
New_c.FSO.WriteTextContent FileName, uXml, True
WV.Navigate FileName
End Sub
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
-
1 Attachment(s)
Re: VB6 WebView2-Binding (Edge-Chromium)
How could I deserialize "Result"?
This does not compile and throws an Argument Byref Invalid error:
Code:
Set Elements = New_c.JSONDecodeToCollection(Result)
Code:
Private Sub WV_JSAsyncResult(Result As Variant, ByVal Token As Currency, ByVal ErrString As String)
Debug.Print ErrString
If Not Token = m_Token Then
Exit Sub
End If
If IsEmpty(Result) Then
Exit Sub
End If
'retrieve a few elements "by selector-expression"
Dim Elements As cCollection
Set Elements = New_c.JSONDecodeToCollection(Result)
This is my JS code:
Code:
async function getActiveLinks() {
let linksArray = [];
let linksSource = Array.from(document.querySelectorAll("a, area, button, select, textarea, object, input:not([type=\"hidden\"]), [role=link], [role=button], [role=combobox], [role=option], [role=textbox], [role=checkbox], [role=menuitem]"));
for (let i = 0; i < linksSource.length; i++) {
if (await isElelementVisible(linksSource[i], true, true)) {
let text = await getTextValue(linksSource[i]);
if (text.length > 0) {
linksArray.push({
text : text,
vsnID: linksSource[i]._vsnEsureId()
});
}
}
}
try {
let thestring=JSON.stringify(linksArray);
alert(thestring);
return thestring;
} catch (e) {
alert(e);
}
}
And if I try this...
Dim s$
s = Result
VB6 tells me error 447: "Object does not support the current language setting"
Attachment 187435
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
How could I deserialize "Result"?
This does not compile and throws an Argument Byref Invalid error:
Code:
Set Elements = New_c.JSONDecodeToCollection(Result)
Please try explicit conversion of the Variant Result to a String:
Set Elements = New_c.JSONDecodeToCollection(CStr(Result))
The VB6-compiler is a bit picky in this case, because both -
Result is a "ByRef" Param and JSONDecodeToCol(...) also expects a ByRef As String argument)
In other words, VB6 would not have any complaints about passing -
e.g. a Variant-Return-Result of a VB-Function (like e.g. WV.jsRun()) into the JSONDecode-Byref argument directly.
Here is an example, which works (showing async Result-Handling)
Code:
Option Explicit
Private WithEvents WV As cWebView2, Elements As cCollection, AsyncTokens As cCollection
Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)
With New_c.StringBuilder 'js-helpers
.AddNL "function getElements(sExpr){"
.AddNL " var resArr = []"
.AddNL " for (var e of document.querySelectorAll(sExpr).values()){"
.AddNL " resArr.push({tag:e.tagName, id:e.id, val:e.value, name:e.name, href:e.href})"
.AddNL " }"
.AddNL " return JSON.stringify(resArr)"
.AddNL "}"
.AddNL "function setElementBackgroundById(id, color){"
.AddNL " document.querySelector('#'+id).style.background = color"
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
With New_c.StringBuilder 'two anchors and two buttons as test-HTML-content
.AddNL "<a id='a1' href='#foo'>LinkFoo</a><br>"
.AddNL "<input id='b1' type='button' value='button 1'><br>"
.AddNL "<a id='a2' href='#bar'>LinkBar</a><br>"
.AddNL "<input id='b2' type='button' value='button 2'><br>"
WV.NavigateToString .ToString
End With
Set AsyncTokens = New_c.Collection(False)
'retrieve a few elements asynchronously "by selector-expression"
AsyncTokens.Add "getElements", WV.jsRunAsync("getElements", "a, input")
End Sub
Private Sub WV_JSAsyncResult(Result As Variant, ByVal Token As Currency, ByVal ErrString As String)
If Not AsyncTokens.Exists(Token) Then Exit Sub
Dim JobType As String: JobType = AsyncTokens(Token): AsyncTokens.Remove Token
Select Case LCase$(JobType)
Case "getelements"
Set Elements = New_c.JSONDecodeToCollection(CStr(Result))
Dim Elmt As cCollection 'the enumerated Elements themselves are (again) of type cCollection - but hold a JSON-Object instead of a JSON-array
For Each Elmt In Elements 'iteration over the gathered Element-Objects in the JSON-Array: Elements
Debug.Print Elmt.SerializeToJSONString 'just to show, which properties are contained "per element"
Select Case UCase$(Elmt("tag")) 'first Property-access on an Element (here the "tag"-Property)
Case "A": WV.jsRun "setElementBackgroundById", Elmt("id"), "#f00"
Case "INPUT": WV.jsRun "setElementBackgroundById", Elmt("id"), "#0f0"
End Select
Next
End Select
End Sub
The other error you'getting is probably related, to not returning a String (but a COM-wrapped js-Object).
Please ensure, that you also return a String in case of an Error... (from your js-Functions - e.g. via return e.message in the catch-branch).
It is then relatively easy, to check whether the first char of such a String is either "{" or "[" == a JSON-String ... otherwise an error-string.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
how to get text from xpath:
Code:
Function GetXpathText(Xpath As String) As String
Dim js As String
js = "document.evaluate(""" & Xpath & """, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"
GetXpathText = Web1.jsProp(js)
End Function
Code:
Dim js As String
js = "document.evaluate(""" & Xpath & """, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"
js = "alert(" & js & ")"
Web1.ExecuteScript js
alert is ok,but jsProp err,why?
Code:
Function GetXpathText(Xpath As String) As String
Dim js As String
js = "var XPathText=document.evaluate(""" & Xpath & """, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"
Web1.ExecuteScript js
doevents
GetXpathText = Web1.jsProp("XPathText")
End Function
'Web1.jsProp("XPathText.innerText")
Function GetTextByXpath(Xpath As String, Optional Method As String = ".innerText") As String
Dim js As String
js = "var XPathText=document.evaluate(""" & Xpath & """, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue"
Web1.ExecuteScript js
doevents
GetTextByXpath = Web1.jsProp("XPathText" & Method)
End Function
Is there a built-in method or more efficient technology that can run this?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Using my old browser, I defined a callback object (a COM dll) and a sub which would be called by the JS.
Can you tell me how I would do that with your browser? This is mycode:
Code:
async function exportChatAsXMLHelper(params){
let displayname = params[0];
let includeMedia = params[1];
let debug = params[2];
let xml = await exportChatAsXML(displayname, includeMedia, debug);
//where is JSCallbackReceiver defined? it is from vb6
window.JSCallbackReceiver.OnWhatsAppXMLReceived(xml);
}
async function exportChatAsXML(displayname, includeMedia, debug){
//displayname, includeMedia, debug
let chat = (await WPP.chat.list()).find(m => m.contact && m.contact.name && m.contact.name.includes(displayname));
await WPP.chat.openChatBottom(chat.id);
let msgs = await WPP.chat.getMessages(chat.id, {count : -1});
const log = (obj) => debug && console.log(obj);
log('Total messages: ' + msgs.length);
let xml = '';
xml+= '<messages>';
for (var i = 0; i < msgs.length; i++) {
log('Message number: ' + i);
let message = msgs[i];
xml+= '<message>';
xml+= '<sender>'+ message.from.user +'</sender>';
xml+= '<receiver>'+ message.to.user +'</receiver>';
xml+= '<type>'+ (message.type || '') +'</type>';
if(message.type == 'chat'){
xml+= '<body>'+ message.body +'</body>';
}
if(message.type != 'chat' && includeMedia) {
xml+= '<media>';
xml+= '<caption>'+ (message.caption || '') +'</caption>';
xml+= '<filename>'+ (message.filename || '') +'</filename>';
log('Downloading media');
try{
let mediabody = await mediatoBase64(message.id);
xml+= '<MediaDownloadStatus>success</MediaDownloadStatus>';
xml+= '<base64>'+ mediabody +'</base64>';
}
catch(e){
xml+= '<base64></base64>';
xml+= '<MediaDownloadStatus>fail</MediaDownloadStatus>';
}
xml+= '</media>';
}
xml+= '</message>';
}
xml+= '</messages>';
return xml;
}
//-----
async function mediatoBase64(msgid) {
let blob = await WPP.chat.downloadMedia(msgid);
return new Promise((resolve, _) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.readAsDataURL(blob);
});
}
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Using my old browser, I defined a callback object (a COM dll) and a sub which would be called by the JS.
WV.AddObject is your friend...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Olaf, I love your work!
Thank you so much!!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Could you tell me how I would call this from VB6?
Code:
async function exportChatAsXMLHelper(params){
let displayname = params[0];
let includeMedia = params[1];
let debug = params[2];
//alert(displayname);
await exportChatAsXML(displayname, includeMedia, debug);
}
async function exportChatAsXML(displayname, includeMedia, debug)
{
let chat = null;
if(displayname != ''){
chat = (await WPP.chat.list()).find(m => m.contact && m.contact.name && m.contact.name.includes(displayname));
} else {
chat = (await WPP.chat.list()).find(m => m.active);
}
await WPP.chat.openChatBottom(chat.id);
let msgs = await WPP.chat.getMessages(chat.id, {count : -1});
const log = (obj) => debug && console.log(obj);
//alert(msgs.length);
log('Total messages: ' + msgs.length);
let count=msgs.length;
for (var i = 0; i < count; i++) {
log('Message number: ' + i);
let message = msgs[i];
let xml='';
xml+= '<message>';
xml+= '<sender>'+ message.from.user +'</sender>';
xml+= '<receiver>'+ message.to.user +'</receiver>';
xml+= '<type>'+ (message.type || '') +'</type>';
if(message.type == 'chat')
{
xml+= '<body>'+ message.body +'</body>';
}
if(message.type != 'chat' && includeMedia)
{
xml+= '<media>';
xml+= '<caption>'+ (message.caption || '') +'</caption>';
xml+= '<filename>'+ (message.filename || '') +'</filename>';
log('Downloading media');
try
{
let mediabody = await mediatoBase64(message.id);
xml+= '<MediaDownloadStatus>success</MediaDownloadStatus>';
xml+= '<base64>'+ mediabody +'</base64>';
}
catch(e)
{
xml+= '<base64></base64>';
xml+= '<MediaDownloadStatus>fail</MediaDownloadStatus>';
}
xml+= '</media>';
}
if (i>50)
{
//alert('exit!');
// break;
}
xml+= '</message>';
//where is JSCallbackReceiver defined? it is from vb6
TheApp.OnWhatsAppXMLReceived(xml,i, count);
xml='';
}
// xml+= '</messages>';
// return xml;
}
I have tried this, but it threw an "Object not defined" error:
Code:
WV.CallByName Array(sChatName, True, False), "exportChatAsXMLHelper", VbSet
Public Sub OnWhatsAppXMLReceived(ByVal xml As String, ByVal index As Long, ByVal max As Long)
End Sub
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
I have tried this, but it threw an "Object not defined" error:
Code:
WV.CallByName Array(sChatName, True, False), "exportChatAsXMLHelper", VbSet
Public Sub OnWhatsAppXMLReceived(ByVal xml As String, ByVal index As Long, ByVal max As Long)
End Sub
Not sure, why you're using WV.CallByName, when it was already established,
that js-functions shall be called via either:
- WV.jsRun( "someJsFunction", ..., ... ) or
- WV.jsRunAsync "someOtherFunc", ..., ...
Also cannot deduce the purpose of your intermediate function (exportChatAsXMLHelper) -
you can call the main-routine perfectly fine (with its 3 arguments) via e.g. WV.jsAsync...
Here is an example again:
Code:
Option Explicit
Private WithEvents WV As cWebView2, Elements As cCollection
Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)
WV.AddObject "TheApp", Me
With New_c.StringBuilder
.AddNL "async function exportChatAsXML(displayname, includeMedia, debug){"
.AddNL " TheApp.ReportIncomingArguments(displayname, includeMedia, debug)"
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
WV.NavigateToString "Dummy-Document-Content"
WV.jsRunAsync "exportChatAsXML", "TheDisplayName", True, False
End Sub
Public Sub ReportIncomingArguments(sDisplayname, bIncludeMedia, bDebug)
Debug.Print sDisplayname, bIncludeMedia, bDebug
End Sub
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The error that I'm getting is not really related to the browser, I guess, but I wanted to ask anyway.
https://drive.google.com/file/d/1WwW...ew?usp=sharing
I am injecting the script using AddScriptToExecuteOnDocumentCreated.
I have successfully done this:
Public Sub ReportIncomingArguments(sDisplayname, bIncludeMedia, bDebug)
Debug.Print sDisplayname, bIncludeMedia, bDebug
End Sub
However, when I try to use my WhatsApp function, I get an error saying
VM11:2 Module Conn was not found with e=>e.Conn&&e.ConnImpl
get @ VM11:2
VM11:2 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on')
at E.<anonymous> (<anonymous>:2:164253)
at E.emitAsync (<anonymous>:2:53133)
at <anonymous>:2:239794
at a (runtime.276e78425ec3861add7e.js:1:15161)
at Array.forEach (<anonymous>)
at runtime.276e78425ec3861add7e.js:1:15333
at runtime.276e78425ec3861add7e.js:1:15393
at runtime.276e78425ec3861add7e.js:1:15397
What could I check to find out where it goes wrong?
The JS file was done by somebody else. I don't know where the webpack code came from.
But I know that I successfully used the JS in my old browser.
If anybody can suggest what to try to pinpoint the problem, I would be glad.
Thank you!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
The error that I'm getting is not really related to the browser, I guess, but I wanted to ask anyway.
https://drive.google.com/file/d/1WwW...ew?usp=sharing
...
However, when I try to use my WhatsApp function, I get an error saying
VM11:2 Module Conn was not found with e=>e.Conn&&e.ConnImpl
Looks like:
- another js-dependency (or js-module) is still missing (not pre-loaded)...
- or your larger js-block runs "too early" (try loading it in WV_DocumentComplete with WV.ExecuteScript instead)
- or the script-code needs to be run from within a script tag with attribute type='module': https://stackoverflow.com/questions/...-module-syntax
Best advice I can give at this point, is to get yourself help from a js-Expert...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I did that, and it turned out that the webpack code was either outdated or malformed in some way.
Olaf, your components help me to pay my living since 20 years :-)
-
Re: VB6 WebView2-Binding (Edge-Chromium)
If I have added code using "AddScriptToExecuteOnDocumentCreated", how would I clear that again?
I have not checked, but I am afraid that some parts of the JS may be double as I add several JS files.
And some websites do not need all of these scripts.
That is why I wonder if I should do housekeeping and keep everything clean.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
If I have added code using "AddScriptToExecuteOnDocumentCreated", how would I clear that again?
I have not checked, but I am afraid that some parts of the JS may be double as I add several JS files.
And some websites do not need all of these scripts.
That is why I wonder if I should do housekeeping and keep everything clean.
As already mentioned in my last post - an alternative way to add script-modules,
is to do it in the DocumentComplete-Event... via WV.ExecuteScript your-module-source-code.
Within that event you can react conditionally what to load, depending on the current Document-URL.
AddScriptToExecuteOnDocumentCreated is useful for:
- truly generic, never-changing helper-functions - which work and are useful on any site
- or to cover very specific "local" or "single-site" scenarios
...(using the current WV-instance which was placed on a specific Form).
Also keep in mind that, when you e.g. write your own UserControl -
you can have different WV-instances (each of them bound to the internal UserControl.hWnd)...
Such a control could have its own Public URL-Property Let and Get ...
and multiple instances of such a UC could be arranged for e.g. "tabbed Browsing".
You could decide, what dependencies you will load - by looking at the incoming NewURL-Param in the URL-Prop-Let-routine.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Olaf, are you aware of that RemoteMessenger.postSyncRequestMessage error popping up in the DevToolsWindow each time?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Olaf, are you aware of that RemoteMessenger.postSyncRequestMessage error popping up in the DevToolsWindow each time?
Yes, it will be fixed in the next release.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
Please explain yourself properly (instead of posting dubious links to some "betting-websites").
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Would it have any bad impact if I have 2 instances of the browser?
I am not sure if there is a way to make something like tabs.
I would like to quickly switch from etc. google.com to youtube.com.
I manipulate the DOM and execute scripts on these websites. I am currently stuck because my google.com scripts and youtube.com scripts interfere. I guess I can make that work, but I would anyways like to ask if it woul be good practice to keep these 2 apart by using 2 browser instances.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
It is best to create two processes, otherwise if two web pages run in one thread, the speed will become slower
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
It is best to create two processes, otherwise if two web pages run in one thread, the speed will become slower
The chromium-engine (which MS-Edge-WebView2 is using under the covers) -
is already working "multi-process-based" underneath - a short view into the Taskmanager would show you that...
So, the hWnd a Client-Process (the VB6-App) will bind a WV-instance to,
is only the "tip of the iceberg" (a ViewPort-rectangle) - these multiple chromium-processes finally "Blit-to" -
(and in the opposite direction, will only receive KeyBoard- and Mouse-Messages from)...
So, no - there is no performance-penalty (and also no memory-problem) with multiple WV-instances in a given VB-App.
Besides, could you please post only about topics you're really knowledgeable about?
(and if you do, then in "better understandable english").
Currently you come across as a "spamming lunatic", resembling a "badly implemented chat-bot".
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Currently you come across as a "spamming lunatic", resembling a "badly implemented chat-bot".
Olaf
that is perfectly correct!
you had to dare to say it! Thanks Olaf for making it !
:bigyello:
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hi Olaf,
you have the method "OpenDevToolsWindow", could you please also add "CloseDevToolsWindow" to the API?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Bob17
Hi Olaf,
you have the method "OpenDevToolsWindow", could you please also add "CloseDevToolsWindow" to the API?
AFAIK, there's currently no built-in method in the official typelib for that...
So you have to go via "normal API" (e.g. using FindWindow - the Window seems always to start with the Caption-prefix "DevTools").
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hi Olaf,
How to use the "SetFuncObj" method?
Thanks!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
paliadoyo
How to use the "SetFuncObj" method?
It's a method, meant for "RC6-internal-use" (to establish easier communication with the js_side of the WV2 in the initialization-phase) -
and I had to make it a Public-Method instead of Friend, for OLE-marshaling to work...)
Once a WV is initialized, the "official UserApi" to place COM-instances in the js-context (e.g for callback-purposes), is:
WV.AddObject ..., ...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Is there any way to block this error from occuring until the new version has been released? It is pretty distracting in the dev console window.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
It's a method, meant for "RC6-internal-use" (to establish easier communication with the js_side of the WV2 in the initialization-phase) -
and I had to make it a Public-Method instead of Friend, for OLE-marshaling to work...)
Once a WV is initialized, the "official UserApi" to place COM-instances in the js-context (e.g for callback-purposes), is:
WV.AddObject ..., ...
Olaf
Perfect. Thanks!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Under some circumstances, "WV.DocumentURL" might take around 3 seconds.
If I get it in WV_DocumentComplete like this...
Code:
Private Sub WV_DocumentComplete()
g_sCurrentURL = WV.DocumentURL
g_sCurrentTitle = WV.DocumentTitle
... it is always fast.
However, when I call it at other times, it might take up to 3 seconds. That is why I store it in WV_DocumentComplete.
Thanks!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I can execute JS on "https://google.de" or "https://google.com.tr" just fine.
On "https://google.com", it does not work.
Is anybody familiar with this?
I will post a sample project shortly.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I can execute JS on "https://google.de" or "https://google.com.tr" just fine.
On "https://google.com", it does not work.
Is anybody familiar with this?
Here is a sample project: https://drive.google.com/file/d/1aYj...ew?usp=sharing
And here is a video: https://www.youtube.com/watch?v=Snz8JN6zGw4
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Code:
window.addEventListener ? (document.addEventListener("DOMContentLoaded", c, !1), window.addEventListener("load", c, !1)) : window.attachEvent && window.attachEvent("onload", c);
in https://google.com
This broke webview2 host object and other webview2 functions
Code:
(function () {
var b = [function () {
google.tick && google.tick("load", "dcl");
}];
google.dclc = function (a) {
b.length ? b.push(a) : a();
};
function c() {
for (var a = b.shift(); a;) a(), a = b.shift();
}
//window.addEventListener ? (document.addEventListener("DOMContentLoaded", c, !1), window.addEventListener("load", c, !1)) : window.attachEvent && window.attachEvent("onload", c);
}).call(this);
-
Re: VB6 WebView2-Binding (Edge-Chromium)
This morning I woke up wondering if Olaf Schmidt has a Wikipedia entry.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Found cause to following issue, no reply needed.
Hi
I am running into issue with Windows Server 2016 which can't even run the WebView2Demo which results in the following error on launch:
Run-time error '430':
Class does not support Automation or does not support expected interface.
The same version of RC6 controls/dll's on my Windows 10/11 workstations work fine but not on 2016.
Have reinstalled MS Webview2 components and also installed MS Edge Browser to but that didn't help.
Any ideas on what I am missing?
Thanks
Carl
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
carl039
Found cause to following issue, no reply needed.
...I am running into issue with Windows Server 2016 which can't even run the WebView2Demo which results in the following error on launch:
Just out of interest, was it a missing "registration" of the RC6.dll on that server-machine?
(or something else)?
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
carl039
Found cause to following issue, no reply needed.
Hi
I am running into issue with Windows Server 2016 which can't even run the WebView2Demo which results in the following error on launch:
Run-time error '430':
Class does not support Automation or does not support expected interface.
The same version of RC6 controls/dll's on my Windows 10/11 workstations work fine but not on 2016.
Have reinstalled MS Webview2 components and also installed MS Edge Browser to but that didn't help.
Any ideas on what I am missing?
Thanks
Carl
Official: Microsoft Edge WebView2 profile - Microsoft Edge Development | Microsoft Learn
https://learn.microsoft.com/zh-cn/mi...edge/webview2/
WebView2 runtime version 109 is the final version that supports the following versions of Windows. The WebView2 runtime and SDK version 110.0.1519.0 and later do not support these operating systems.
Windows 8/8.1
Windows 7
Windows Server 2012 R2
Windows Server 2012
Windows Server 2008 R2
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I heard that there is a way to read and write MYSQL database without installing the driver, just extract a DLL like SQLITE3.DLL?
Maybe a special ADOx86.DLL,ado x64.dll? Can I read and write to the database without installation?
This way, different operating systems will have the same experience and won't cause all kinds of compatibility issues and errors.
EDGE, for example, has a version 109 that supports older Windows 7, Windows 8, and so on. But he can't have a single DLL for all operating systems.
MINIBLINK.DLL does this (a DLL is only 17m-35M, it's like installing IE11, an old version of Google Chrome, some of which is not supported, but works perfectly with electron,node js), but the latest version is only blink 75. Now Google is in version 113
-
Re: VB6 WebView2-Binding (Edge-Chromium)
i want to show webview by vb.net with rc6.dll
In the SHARPDEVELOP developer tool, the reference to RC6.DLL does not show the class
Unable to load type library referencing "RC6". The library is not registered. (Exception from HRESULT:0x8002801D (TYPE_E_LIBNOTREGISTERED)) (MSB3287)
Is your RC6.DLL developed in VC++2010? It took me a lot of time to install the WINDOWS 8.0SDK before I could compile it
HOW TO USE IN VB.NET?LIKE THIS
Next you need to register the DLL. Select the Start menu's Run command and execute the statement:
regsvr32 VB6Project.dll
Next start a Visual Basic .NET project. Select the Project menu's Add Reference command. Click the COM tab and find the DLL or click the Browse button to select it. Now the .NET application can use the DLL's public classes as shown in the following code.
Code:
Private Sub btnCallSubroutine_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnCallSubroutine.Click
Dim vb6_class As New VB6Project.MyVB6Class
vb6_class.VB6SayHi()
End Sub
Private Sub btnCallFunction_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnCallFunction.Click
Dim vb6_class As New VB6Project.MyVB6Class
MessageBox.Show("Returned: " & vb6_class.VB6ReturnHi())
End Sub
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Those last two posts do not appear to be related in any way to the topic at hand. The topic does seem to have wandered a bit, so the second one is kind of on topic, but not the post about SQLLite.