Thanks jpbro, nice to see it was something relatively simple to fix. I've got the demo compiling and running now. Now I'll have to work out how best to build it into my application and see how it runs there.
Printable View
Maybe the following example is useful to you:
https://www.vbforums.com/showthread....-WebView2-Demo
Hi Olaf,
I'm trying to install Webview2Demo. I followed the instructions but I get the error:"Procedure declaration does not match description of event or procedure having the same name". Any ideas why. Thank you very much!
-Jack
one question:
using the example and navigating to "google.com", I can't seem to be able to get the "document.getElementById('btn1').innerHTML" working using WV.jsProp. Any ideas? basically, I need the html of the entire page I just navigated to. I assume I can do so using "body.innerHTML"
Is there a way to invoke a js click such as
WV.jsRun("document.getElementById('Somebutton')".click()")
I was unable to invoke a click with that
thanks for your help!
That helps, thanks again!!
what's MicrosoftEdgeWebView2Runtime?
Is the development version of the interface open?
How to operate the EDGE that is installed or that comes with WIN10, can I control the CHROME kernel without installing any RUNTIME? Maybe only Google Control Protocol, based on HTTP port, like WEBDRIVER?
The CHROME kernel environment, there are three ways to get:
Install the EDGE (Chromium) of the development version, the stable version of the EDGE does not currently support WebView2 controls.
Install independent WebView2 Runtime, which can download and upgrade an EDGE Chromium kernel separately
Embedding Edge Chromium kernel
I don't know if there's a way. Do not need to install, only need to extract the file, and Have the least hard disk space
Edge Webview2 Automatic installation, detect the installed version-VBForums
https://www.vbforums.com/showthread....talled-version
How to use code-behind automatic installation MicrosoftEdgeWebView2RuntimeInstallerX86?
https://msedge.sf.dl.delivery.mp.mic...stallerX86.exe
Which URL can use the code to automatically download the latest version? Plus automatic installation is very convenient
【install used 32 seconds, occupying 444mb of hard disk space】
use miniblink.DLL or cef.DLL(10-50MB)
For the chromium kernel, only one DLL is needed. Use this mini-small WEBKIT-related kernel as much as possible. If some web pages are too complicated and require the latest HTML5 technology to display, then use Microsoft's EDGE runtime library. 450Mb is more than 10-50mb, which takes up too much hard disk space.
install used 32 seconds, occupying 444mb of hard disk spaceCode:Function CheckSetupOk() As Boolean
'It takes 10 seconds to check whether the edge runtime component is installed successfully. Is there a faster method?
Dim WV As cWebView2
Set WV = New_c.WebView2
CheckSetupOk = WV.BindTo(Me.hWnd) <> 0
Set WV = Nothing
End Function
Function DonwSetupTool() As Boolean
Dim URL As String
URL = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
'xmlhttp download***
'save as :Edge_Webview2RunTime.exe
Dim Size1 As Long
Size1 = FileLen(App.Path & "\Edge_Webview2RunTime.exe")
DonwSetupTool = Size1 > 1024 ^ 2
end function
I don’t know if there is a silent installation parameter to prevent him from displaying the download and installation interface
MicrosoftEdgeWebview2Setup.exe /silent /install
check Registry information:
Microsoft Edge WebView2 Runtim(92.0.902.8)
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
get string value(PV and name)
You can keep it updated automatically. It's also very convenient. Ie is very rubbish, the edge of the Microsoft's last Straw, he will certainly operate very well.
But if you want to take up less memory, take up less hard disk space, install a fixed old version, this is a better choice.
Yes, of course - but on each of the target-systems, this "base-runtime-installation" will only have to be done once
(as the "evergreen" suggests, this chromium-runtime will from this point on, be updated by the system).
As for detection, whether a given target-system already contains this runtime,
you can simply check the output of the GetMostRecentInstallPath-method:
strInstallPath = WV.GetMostRecentInstallPath
If it gives back an empty string, then you need to inform the user,
to download the little 1.7MB base-installer from the MS-webpage via this (apparently constant) Link -
(as already given in the Opener-Posting of this thread):
https://go.microsoft.com/fwlink/p/?LinkId=2124703
If you ask your user beforehand like this:
The little 1.7MB MS-Executable from that download above, will then determine which system the User actually runs (Win7, Win8, Win10) -Code:If Len(WV.GetMostRecentInstallPath) = 0 Then 'Edge-Chromium-Webview is missing on this system
If MsgBox("The needed MS-WebView2-runtime is missing," & vbLf & "Do you want to download the installer now?", vbYesNo) = vbYes Then
New_c.FSO.ShellExecute "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
End If
End If
and then download and install the larger (about 50MB-80MB) and properly matching evergreen-runtime which will work best on the given system.
HTH
Olaf
Because at first I didn't know if. Net directly supported the standard version of the edge.
Just like ie, I thought the system came with WebBrowser controls.
After the win10, win11, the system recommended by default to install the edge browser software, using the Google kernel, if you can bring webview2 control is convenient, otherwise you need to install 500MB runtime.
I just like automatic installation and deployment.The original detection of whether the edge runtime is installed, it takes more than 10 seconds, so later found a way to find the registry.
I spent more than a day on it. I just hope others can avoid detours.
Then I stumbled on the silent installation method.
Thank you for your contribution to the highly encapsulated Google kernel.
I just spent more than an hour reading everyone's replies.Many people do not know the problem they solved, but did not leave detailed code.
Is there a way to open the privacy page?
For example, create two webview objects in a form.
But the cookie between them is quarantine each other, is there such a setting?
If you create objects in multiple threads and use multiple webview controls in the same window, can you improve the running speed?
IE WebBrowser may run in the STA mode. If you create it in multi-thread, the webpage will not show, even if the creation is successful, the running speed is also very slow, and it is actually a message queue processing, eventually is running in the same thread. in.
After my test. The new computer is not installed with WebView Runtime, nor will it be wrong. This is a creating an object, I will be snatched 10 seconds, then the prompt fails. In this case, the automatic download of the runtime installer will be successfully created after the installation is complete.
There is also a problem, rc6.dll. Are there any plans to launch a 64-bit version?
In this way, VBA, 64-bit office, VB. Net and other IDE or development tools can also use it.
Twinbasic, and many other IDE alternatives to VB6 are under development, many of which can generate 64-bit exeThe biggest disadvantage of Microsoft's VB6 is that it does not support 64-bit, but VBA has a 64-bit version
Are there any plans to develop a simple webdriver like interface?
It just uses HTTP or websocket to control a properly installed Google Chrome or Edge browser.
You do not need to install a development version of edge or a webview runtime.
Almost eighty or ninety percent of computers have Google Chrome installed.
There is an open source project based on the COM interface of Google webview driver. But it hasn't been updated for many years.
A good technician can compile it to 64 bits.And add some of the latest version of the function, because there are some functions have been wrong or outdated.
vb6 webdriver,support vba,call edge chrome,
msedgedriver.exe
Without systematic teaching materials, many people will only use simple open web pages.
I've tested this before, getting all the tabs, switching between any of them, and it's very time consuming to debug.
So if you can have a master sub-installed easier to use, many people will not need to learn to use.
JS, database, network programming, interface beautification, Google browser control, these areas have great market potential in the future.
https://blog.csdn.net/qq_24499417/ar...ails/105602339
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Microsoft WIN11 preinstalled messaging APP teams 2.0 experience: Built on Edge Webview 2 2021-08-18
Just saw the news, the future win11 comes with a webview2 runtime.
There is no need to download and install it manually in the future, so it is much more convenient.
If we study webdriver more thoroughly, what browser is automatically detected on the client? Automatically download the driver, automatically open the web page and automatically fill in the form.
Applications such as Microsoft Office have begun to deploy WebView2 Runtime in their applications. WebView 2 Runtime has been installed on more than 200 million Windows devices.
Hello Olaf
Is it possible to add the management of the new DownloadStarting event of webview2 in RC6 ?.
This would allow to change the default download directory.
Thanks a lot
François
Here is the link to Microsoft Documentation of this new event
WebView2 Win32 C++ ICoreWebView2_4 | Microsoft Docs
Dear Olaf,
First thing first. Thanks a TONNN, as ever. It was great seeing your demo in action! Wow!
Actually, fortunate that I stumbled on this forum page (when I was really desperate to find a demo on how to use WebView2 in your RC6). How I wish all these demos of yours (or) links to these kinds of forum pages were in your vbRichClient.com website in one page! Anyway, I fully understand your lack of time.
Well, you have asked us to let you know if something is not working. I am just giving hereunder what happened when I ran the demo:
1. For the following procedures, VB6 reported "Compile error: Procedure declaration does not match description of event or procedure having the same name"
Code:Private Sub WV_AcceleratorKeyPressed(ByVal KeyState As eWebView2AccKeyState, ByVal IsExtendedKey As Long, ByVal WasKeyDown As Long, ByVal IsKeyReleased As Long, ByVal IsMenuKeyDown As Long, ByVal RepeatCount As Long, ByVal ScanCode As Long, IsHandled As Long)
Debug.Print "WV_AcceleratorKeyPressed"
End Sub
2. Instead of immediately researching on what the abovementioned error could be due to, I just commented out both the above procedures and ran the demo. And, there it was! Your demo in super action! Thanks, Olaf! People like you give lots of joy to persons like me!Code:Private Sub WV_NavigationCompleted(ByVal IsSuccess As Long, ByVal WebErrorStatus As Long)
Debug.Print "WV_NavigationCompleted"
End Sub
Well, why did the compile error pop up for the abovementioned two procedures? Have they to be redeclared with different number/types of parameters? If so, kindly let me know how. In case the Compile error was due to some other reason, then kindly educate me on the same too.
Kind Regards.
See https://www.vbforums.com/showthread....=1#post5530453. Short-answer RC6 is still in a development phase and the method signatures are not yet finalized.
Thanks jpbro. Both the procedures work now!
Kind regards.
Hello,
Using RC6 cWebView2 with the latest Evergreen version of Webview2, on some sites (especially Google sites: Google News, Google Play Store ...) the DocumentURL and DocumentTitle properties remain an empty string once the page is completely displayed.
This does not happen with old fixed versions of webview2 !
Have you encountered this problem?
Is this a Microsoft regression or an RC6-Webview interface problem or Google sites issues ?
Best regards
Note: I am using RC6 6.0.9 on Windows 10
I was able to reproduce that, and the reason is, that Google since a few weeks apparently insists (on some of their Sites) on "higher security" for the eval-function (when called from "self-assigned scripts" - which I use so far, to resolve window-Properties via jsProp Get/Let - as e.g. jsProp("document.title").
Came up with a workaround for the Eval-Function (which formerly worked behind WV.jsProp Get/Let) -
and it will be present in the next Release 6.0.10... (want to wait until SQLite 3.37 gets released at december 1'th)
Olaf
// Deutsch
Sehr geehrter Herr Schmidt,
ich hätte gern gewusst, ob Sie das webResourceRequested-Event in RC6.DLL zur Verfügung stellen können, sowie wie Sie ans ICoreWebView2-Interface dran kommen können.
Vielen Dank im Voraus für Ihre Rückmeldung!
Mit freundlichen Grüßen
Igli Kapri
// Englisch
Dear Mr. Schmidt,
I would like to know whether You can provide the webResourceRequested-Event in RC6.DLL as well as how You find the ICoreWebView2 interface in .NET.
Thank you very much in advance for Your response!
Kind regards,
Igli Kapri
vb6+cwebview2 is good thing
but did somebody know why could not upload file in vb6 cwebview2 edge browser?
some web could, but most important web could not use web file upload system. What a pity.Attachment 183090
How can I click a button on the page?
I have tried
WV.jsRun ("document.getElementById('btnSubmit').click")
But nothing happened
In WebViewInit
'we can predefine our own set of js-functions, before any document gets loaded
WV.AddScriptToExecuteOnDocumentCreated "function ElementClick(myElement){ window.document.getElementById(myElement).click(); }"
'after document load we can use
WV.jsRun "ElementClick", "btnSubmit"
jsRun is thought for function-calls, which allow you to pass parameters as normal VB-Vars.
For such longer "multi-dotted-expressions" (with "inner, literal-arguments"), you are better advised to use:
WV.ExecuteScript "document.getElementById('btnSubmit').click()"
Please note the trailing parentheses behind the last methodname "click".
Olaf
Hi.
Unfortunately, due to the security feature of the Edge Browser, I cannot access local files, e.g. something like this: file: /// C: /Pictures/loading.gif
Error message in the console: Not allowed to load local resource
How can I change the security settings to allow local resources?
thx Andreas
There's a huge deal of influence possible, via the CommandLine-Parameter of the intial Binding-Call...
I've posted a Link to it already in an earlier posting here in this thread,
but here is it again (already jumping to a setting which might work for you):
https://peter.sh/experiments/chromiu...ess-from-files
If this specific one doesn't, other flags might do the job (perhaps google a bit about it,
using the term CEF in your searches).
Olaf
Thanks for the link. I hadn't seen the website yet. I wish many dear and happy holidays...
I know that using chromedirver. can intercept the image of the specified element
By the following command
/session/" & m_StrSessionId & "/element/" & m_StrElementId & "/screenshot.
Do you support this function?Quote:
Private Sub cmdCaptureWV_Click()
Dim Srf As cCairoSurface
Set Srf = WV.CapturePreview(CaptureAs_PNG) 'capture the current WV-Window as a Cairo-Image-Surface
Srf.WriteContentToPngFile App.Path & "\WV_Capture.png" 'which we can now visualize, or just write out as a PNG-file
End Sub
No, there's no Element-based ScreenShot-feature (what's built-in, is working Window-based).
One could get around making that "bigger ScreenShot" -
then getting the surrounding rect of the Element via javascript -
followed by cutting out the Sub-Bitmap using these coords...
But if this is for Unit-Testing... that's what chromedriver is made for and specialized in
(not only with regards to the ScreenShot-feature) ... so, why not use it furhter?
Olaf
We know that Google Chrome can set the capabilities parameter to customize the functions of the browser through chromdirver. I don’t know if you have this setting.For example: disable camera ...
I want to replace the js function loaded in the original webpage.how can i do
Originalfunnctio is checkCamera
WV.ExecuteScript "checkCamera= function myfunction(){}" ?
We know that Edge-Chromium can set the capabilities parameter to customize the functions of the browser through Edgedirver. I don’t know if you have this setting.For example: disable camera ...
I want to replace the js function loaded in the original webpage.how can i do
Originalfunnctio is checkCamera
WV.ExecuteScript "checkCamera= function myfunction(){}" ?
As already said a few posting further above - there is a ton of startup-settings,
you can set and combine via the commandline-parameter of the initial Bind-Call.
Here is the link again: https://peter.sh/experiments/chromiu...line-switches/
(if you search via <Ctrl><F>, you will find a lot things to influence "media" or "capture"-behaviour.)
Olaf
thanks.
I am not very proficient in JS.I have to try to use Js.
Hi Olaf and thanks for your great work!
I have a "stupid issue" to report regarding UserContextMenu event: the ScreenY argument declaration is spelled wrong: "SreenY" :)
Someting more serious: are you planning to map the NavigationStarting Event in the vb6 wrapper so that is possible to detect the destination url before the navigation effectively occurs?
Ciao,
DR
Hi Olaf
I have a question regarding RC6.WebView2.
Is there a way to download an image resource instead of opening it in WebView2? By using Navigate, the image is opened in WebView2 instead of invoking the download operation. I'd like that image to be downloaded the way I navigate to a zip file.
Well, I know I could get the image url and use a separate httpclient to download the file. But anyway to use the WebView2?
Plus it doesn't seem the RC6.WebView2 provide anything related to downloading.
Thanks in advance.
Hello,
I downladed RC6 a few days ago from vbRichClient.com and I registered RC6.dll with the aid of RegisterRC6inPlace.vbs.
Then I installed the "evergreen-WebView2-runtime" via the MS-download-link.
I tried to run WebView2Demo.vbp, got the error "Procedure declaration does not match description ..." and corrected the code as explained in post #60.
Now I expected the demo to run, but it always stops in the following line:
with the following error message:Code:If WV.BindTo(picWV.hWnd) = 0 Then MsgBox "couldn't initialize WebView-Binding": Exit Sub
"Runtime Error 53:
Error in FindFirstFile: ErrNum: 3, The system cannot find the path specified."
(I'm using VB6 Version 8176 under Win10Pro).
Any ideas what is wrong or what I did wrong?
There seems to be a problem with the installation of the WebView-Runtime...
The BindTo-call is looking for the WebView-Runtime-BaseFolder via the following Path-Expression:
(for your Immediate-Window):
?New_c.FSO.GetSpecialFolder(CSIDL_PROGRAM_FILESX86) & "\Microsoft\EdgeWebView\Application"
When I paste the above into my immediate-window (followed by pressing <Return>),
then it prints out:
C:\Program Files (x86)\Microsoft\EdgeWebView\Application
This path exists on my machine (when I paste it into Explorer.exe, it shows the content)...
Under this path, the BindTo-call then continues, to list determine the Folder with the highest Version-Number...
So, could you check what your immediate-window says, the Base-InstallPath of the WebView-runtime is -
and whether it exists on your machine?
HTH
Olaf
The output of the Immediate Window is: C:\Program Files (x86)\Microsoft\EdgeWebView\Application
This path does not exist on my machine!
Some minutes ago I re-installed "evergreen-WebView2-runtime" via the MS-DownloadLink, which took place without problems (which was also the case during the first installation), and now the path \EdgeWebView\Application exists and the demo program is running!
Thank you very much for your quick help!
Save As is not available in web pages
"Save As..." is available in the Default-Context-menu...
and it will work, when you do not run elevated as an Administrator (as is the case e.g. in the IDE)...
When you run a compiled version, it should pop-up the FileDialog (for you to choose a Save-target).
(MS knows about the problem in Admin-Mode, there is a ticket for it: https://github.com/MicrosoftEdge/Web...ack/issues/802)
HTH
Olaf
thanks
Once again thanks to Olaf for his help and generally for his great work!
Now I'm succesful with the WebView2Demo.vbp, added a second picturebox named "Pchart" and wanted to copy the let's say "browsing result", i.e. the image in picWV, into this second picturebox. I tried:
PChart.Picture = picWV.Image
but obviously that doesn't work.
Any ideas on how to get this done?
The PictureBox picWV which is used in the Demo, is only providing "a Container-hWnd" for the Browser-instance,
(which places its own Browser-hWnd as a Child inside the picWV.hWnd).
But there is a builtin Method, which captures the current Browser-Content as a Pixel-Graphic
(returning a cCairoSurface-Object, which you can use for all kind of purposes, e.g. writing to a PNG-ByteArray or -File for example)
Long story short - please try:
Set PChart.Picture = WV.CapturePreview(CaptureAs_PNG).Picture
Olaf
I saw the following part in the demo:
Dim Srf As cCairoSurface
Set Srf = WV.CapturePreview(CaptureAs_PNG) 'capture the current WV-Window as a Cairo-Image-Surface
Srf.WriteContentToPngFile App.Path & "\WV_Capture.png" 'which we can now visualize, or just write out as a PNG-file
but was not able to transform this into the syntax:
Set PChart.Picture = WV.CapturePreview(CaptureAs_PNG).Picture
Long story short: You code works like a charm - thank you very much!!!
Best Regards
C-E
The above "one-liner" is just making use of a compiler-feature,
which creates a (hidden) temporary cCairoSurface-instance under the covers,
(from the return-value of the CapturePreview-method) before accessing its Picture-Property...
The PNG-output code could have been written in one line as well -
I just wanted to make it more obvious, what CapturePreview returns.
A cCairoSurface is just a wrapper-class around a "32Bit-Per-Pixel DIB-allocation" in system- (not GPU-) memory -
but also the entry-point into powerful cairo-based (Vector-)Drawing-Commands, which are just "one context-call" away.
E.g. you could easily draw "additional stuff on it" (before placing such a Surface on a PictureBox),
for example - if you want to "frame" the Browser-ScreenShot, you could do it this way:
HTHCode:Dim Srf As cCairoSurface 'make the returned Surface explicit
Set Srf = WV.CapturePreview(CaptureAs_PNG)
With Srf.CreateContext 'enter Drawing-Mode
.SetLineWdth 2
.Rectangle 0, 0, Srf.Width, Srf.Height, True 'define a Rectangle-Path
.SetSourceColor vbRed, 0.5 'define the Border-Color with 50% Alpha
.Stroke 'strokes only the Outline of the Path (not the interiour of the Rect)
End With
Set PChart.Picture = Srf.Picture 'now assign the combined result to the PicBox
Olaf
Hi, everyone.
Also, is it possible to auto-fit a text box to the available width and height so that when the shape is resized, the text box will also resize proportionally to the available area?
From this :
to this:Code:<textarea id=txt1 cols=50 rows=4></textarea>
Kind regardsCode:<textarea id=txt1 height:auto width:auto></textarea>
Andrew
@Olaf First of all fantastic work!! One question:
Would it be possible to extend cWebView2 with a callback when basic authentication is requested from a site so I can provide with user name and password and thereby prevent the Sign in prompt? I.e. my hybrid app first requires a login by the user, and when navigating to my site an additional "Sign in" is currently now needed. Earlier when using the embedded IE control this was automatically handled by WinInet.
Thanks in advance