At the end I did it with a WinHttpRequest object that I already know how to handle and it worked.
Thanks a lot!
Printable View
At the end I did it with a WinHttpRequest object that I already know how to handle and it worked.
Thanks a lot!
Hi Olaf,
Many thanks for developing this.
The current WebResourceResponseReceived event only provides
ReqURI, ReqMethod, RespStatus, RespReasonPhrase, RespHeaders
Could you please implement a way of retrieving the response body (and, preferably, request headers & request body as well)?
Attachment 189031
On a customer's computer I see this message when he / I click the microphone button in web.whatsapp.com.
However, when he / I click on it, the result is not saved.
It's not possible to record audio.
Also,
Private Sub WV_PermissionRequested
is not fired.
What could I be missing?
The problem does not occur on my or (so far) any other customer computer.
Olaf, could you offer a service that assures us "companies" to get support and a maintained product or the source code so that we could continue support it ourselves in case something happens to you?
WebView2 is not a product by Olaf, he just delivers a more easy programming interface using his vbRichClient 6 environment.
https://github.com/MicrosoftEdge/WebView2Browser
https://learn.microsoft.com/en-us/mi...edge/webview2/
That is exactely what I am talking about.
Outside this forum and a few other die-hard hobbyists it's pretty hard to still find a demand for VB6 apps, maybe that's why Olaf isn't selling his RC6 components.
Looking at Arnoutdv's links I can see that this WebView2 stuff is pretty massive, so even if Olaf shared the source code I think most users would find it rather complicated to fix things themselves but at least it would open the gates for other experts to chime in and help out.
I am wondering whether Olaf implemented WebView2 in VB6 or maybe it's all C++ in the RC6 DLL?
The problem also does not occur on my machine.
Keep in mind, that "permission for accessing built-in hardware" (microphone, camera, GPS, etc.)
has to take "more than one hurdle" (the "Privacy-related, BrowserCtl-internal permissions are only one side of the coin).
There's also the "over-ruling" access-permission for such hardware on the outside (at OS-level).
The OS allows, to define such permissions "App-specific" (for all installed "Store-Apps") -
but also for either "all Desktop-Apps generally", or for "specific Process-Names of Desktop-Apps".
(in a kind of WhiteList - probably stored in the registry somewhere).
Remember, that your own "WebView2-using App" (your Executable) does not run under the flag of "MS-Edge" or something.
(somehow inheriting the permissions of the MS-Browser-Executable)...
No, it is an Executable in its own right (which by default is probably not in the "known list of white-listed Apps").
So, try to find a way, to enable Microphone-usage at that outer level first for your App
(e.g. in a Screen-Session, together with your one problem-customer).
Some systems are quite "closed-off" due to over-eager Company-Domain-Admins -
but that's not a problem the RC6-WebView2-Wrapper can solve...
Olaf
All wrapper-classes the RC6.dll exposes, are VB6-implemented, since it's a normal VB6-AX-Dll-Project.
(and that includes cWebView2).
cWebView2 itself interacts with WebView2Loader.dll (which is part of the RC6.dll's "flat-Dll-dependencies") -
and works through this relatively thin MS-provided layer, to talk (via COM-interfaces) -
with the "Evergreen-WebView2-runtime" (about 300-500MB), which MS itself is updating regularly, once installed
(on Win11, that "self-updating, chromium-based BrowserCtl-runtime" comes preinstalled on the system).
Olaf
dim web1 as cWebView2
dim ptr1 as long-web1.webcontrolobjptr
dim obj as object
set obj=web1,WebView2control
Can this object be made public? It is convenient for people in need to do more operations.
Hi Olaf,
can you release the source code of your components so that we can find a way to go on in case something happens to you?
I'd say - let's talk about that, after "something happened to me"... ;)
Besides, there's closed-source COMponents in (heavy) daily use in this community,
which date nearly 20 years back with their "last compile-date" as e.g. the unmaintained:
- MS-Winsock.ocx
- MS-FlexGrid, -HFlexGrid
- MS-CommonControls
- MS-ADODC
And nobody demands from MS, that they open their sources for these controls.
Instead those just work (and work and work) - because they are hardened -
and for the few bugs they might still contain, there's "known workarounds".
If you are that concerned, that a closed-source-component will not work anymore "next week" (as it was, at the last compile-date),
then simply "choose another component" (as e.g. the .NET-wrapper for WebView2) -
it really is that easy - and up to you to decide.
I've mentioned the "conditions" for opening the RC6-sources already several times here in this forum...
(the main-condition being: "a base for long-term-survival" - aka an OpenSourced, platform-independent compiler, which we do not have currently).
Olaf
Olaf,
there is currently no replacement for VB6 for some developers.
I am not releasing any .NET applications to the public because it means giving away your source code.
I know 2 others who run big businesses using VB6 for the same reasons.
I did convert my apps to .NET and decided against releasing them.
People depend on my business.
My softwares are certified and auditioned regularly as they are used in a medical branch.
If you really mean it (regarding "after I am gone"), then can you implement a system that would make the source code accessible to me (and possibly others whose business depend on it)?
I hope, you notice the irony here...? ;)
Besides, you can wrap up (only) the .NET WebView2-functionality in a VB6+COM consumable .NET-assembly
quite easily... no need to rewrite "your whole App in .NET" (please read about .NET<->COM-interop).
There are already "measures in place" (which I tried to convey with my little "joke", which would otherwise be somewhat rude).
Olaf
VB6.0,WebView2,Please advise on how to copy the PNG format webpage verification code into the picture box, boss.
The website is as follows: http://xxpt.scxfks.com/study/captcha
A friend of mine in China has a long life span in his family, and many people spend more than 115 years.
On average, half of them live to be over 100 years old.
He packaged some of the source code into a CD and sold it to many people for a $50 tutorial fee.
In fact, many technologies on our forum are many times more valuable than that.
He is more than 70 years old this year, is a Taiwanese, and has not a single white hair.
This really has a lot to do with heredity. And everyone's way of life.
I wish everyone in here study vb6,vba,vb.net is happy, and everyone is happy to communicate.
After net was abandoned by Microsoft, the number of VB programmers has been decreasing.
In the past 10 years or so, we have probably contributed the most technology and the most powerful technology.
@Schmidt You have contributed a lot of VB6 technology. Rc6, DLL. Is undoubtedly a very great product, if many people can learn to use it. It's really convenient, and it can also add a lot of functions to your software. A lot of development costs are reduced.
It was supposed to be a paid software product for you to use for free, and we are very grateful to you.
I was recently working on a mini version of the MySQL server, which was compressed to just over 2.8 megabytes.For the full version, it will be more than 50 megabytes normally.
Mysqld. Exe, just start the process.
And then set the super initial password. I studied it for two whole days. In fact, the cost is also very high. It can be interpreted as $500.
There is one from 2003 or so. LIBMysql. DLL, less than 1000kb, it can connect to the MySQL server.It's been 20 years and it's still working. It's incredible.
It's a little off topic.It's just that the research cost of some technologies is actually very high.You can choose open source or partial open source. It's all free.
Many small functions are implemented with difficult technology and patented technology.
We should respect the technology of original developers and give more encouragement.
To provide additional services, it must be a VIP who needs to pay extra. You can provide some give some source code or none.
You can't unconditionally ask others to provide you with source code or provide you with more services.
I've asked about this in Microsoft's MSDN support community, as well as in its open source project webviewload. DLL.
It took two years to get back to me that they didn't have any plans to develop VB6 demo code.Although they can adopt or enhance functionality for some bugs or other technical issues.
But they can also refuse 100% or never respond to your needs.
Uch as continuing to offer vb7, VB. Net upgrading
Or provide webview 2.ocx
Hello Olaf,
I am working on a medical management software in France. For security reasons, reading social security cards and physician identification cards from a browser will soon no longer be possible through scripts within the web page, but through approved extensions added to the browser. Until now, I have been using cWebView2 to authenticate myself with these cards, but this will probably no longer be possible in the future.
Apparently, WebView2 can now handle extensions.
Is there a planned update of RC6 that will bring extension management to cWebView2? (Properties AreBrowserExtensionsEnabled, etc…)
Please keep me informed.
Best regards.
François
Ah well, ...finally.
Will see what I can do in this regard over the holidays...
Though, assuming you are aware of the AddObject-functionality (using WebView2 as a UI) -
can't you just implement such "extended-stuff" in VB6-Classes and call it from the WebView?
Olaf
Thank you for your response, Olaf.
I must admit that I am not familiar with the AddObject functionality!
I will try to find examples in the posts of this thread while waiting for integration into cWebView2.
Unless you have a small example?
Best regards, François
It allows to put arbitrary Helper-COM-Objects (no matter, whether Private Classes or Public ones from an AX-Dll) -
into the js-context... (under a certain name-string, which is then case-sensitive in js).
Over such an added Object you can then - at any time:
- "call into VB6-Code" (and thus, into "system-stuff, normally not reachable by a browser")
example-class, named cAuth (in a normal VB-Form-Project):
Code:Option Explicit
Public Function GetWinUserName() 'a Browser does not know the logon-name of the current Win-User
GetWinUserName = Environ("username") 'so we help out with that here, via this little cAuth.Method
End Function
TestForm-Code:
HTHCode:Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Set WV = New_c.WebView2(hWnd, 0) '<-- the 0 ensures async-mode
End Sub
Private Sub Form_Resize()
if Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Private Sub WV_InitComplete()
WV.AddObject "Auth", New cAuth
WV.NavigateToString "<div id='user_div'></div>", 0 '<-- the 0 ensures async-mode
End Sub
Private Sub WV_DocumentComplete()
WV.ExecuteScript "document.querySelector('#user_div').textContent = 'LoggedOnUser: ' + Auth.GetWinUserName()"
End Sub
Olaf
"Thank you Olaf for this example.
However, I don’t see how to switch a WebView2 property inside cWebView2, like AreBrowserExtensionsEnabled to True, through this method.
As said, I'll try to enable this (not yet implemented) Property (and its "sidekicks") over the holidays in a new RC6-version, which enhances cWebView2.
Why are extensions useful?
Because they allow other devs to "break out" of the restricted Browser-environment with either js - or "other (compiling) languages" -
to allow access to e.g. the FileSystem (along with anything else the Host-OS has to offer, which is not "reachable" via the built-in js-engine).
The example in my prior post was just a suggestion... showing an alternative way how to tackle basically the same thing -
(breaking out of the Browser, calling functionality of the underlying OS via VB and system-APIs) -
entirely "on your own", in a language you know well, without waiting for "plugins" to circumvent "browser-limitations".
Olaf
I understand better Olaf, Thank you.
In fact, in my case, I am required to use the extensions approved by the administration to validate the reading of social security cards and physician identification in the browser context. It is also the back-end of the French national shared medical records management application that addresses the extension to authenticate patients and physicians before delivering health information.
I will wait for the update of the RC6.
Best regards.
François
Edit: I think the problem occurs because I prevent new windows from popping up. I will report back.
--------
Still about not receiving the PermissionRequested event for web.whatsapp.com when trying to record an audio message on one customer's computer:
My app is in the list of allowed applications.
My app is able to access the microphone for example using waveInOpen and recording a wav.
The system settings indicate that the admin takes care of system settings.
What should I do now?
Did I understand correctly that you offer to have a look at the customer's computer via Anydesk or similar?
I am running a script as follows:
dim script
script = "var divsListAds = document.querySelectorAll('.mt-ListAds');" & vbCrLf & _
"var hrefArray = [];" & vbCrLf & _
"divsListAds.forEach(function(div) {" & vbCrLf & _
" var links = div.querySelectorAll('a');" & vbCrLf & _
" links.forEach(function(link) {" & vbCrLf & _
" hrefArray.push(link.getAttribute('href'));" & vbCrLf & _
" });" & vbCrLf & _
"});" & vbCrLf & _
"console.log(hrefArray);" & vbCrLf & _
"window.chrome.webview.postMessage(JSON.stringify(hrefArray));"
WV.ExecuteScript script
In the console it shows me the data I need, the question is how can I pass that data to a variable or save that data in a text file, could someone help me?
WV.ExecuteScript is not the right method to tackle such problems...
A better approach is, to encapsulate your js-Codeblock in a function...
and then simply "calling it" later on (after Document-Load) via WV.jsRun()...Code:With New_c.StringBuilder '
.AddNL "function myFunc(){"
.AddNL " var divsListAds = document.querySelectorAll('.mt-ListAds')"
.AddNL " var hrefArray = []"
.AddNL " divsListAds.forEach(function(div){"
.AddNL " var links = div.querySelectorAll('a')"
.AddNL " links.forEach(function(link){"
.AddNL " hrefArray.push(link.getAttribute('href'))"
.AddNL " })"
.AddNL " })"
.AddNL " return JSON.stringify(hrefArray)"
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated (.ToString) 'add the function to the WV-context from StringBuilder-Content
End With
OlafCode:Debug.Print WV.jsRun("myFunc") 'call the js-Function, printing the (stringified) JSON into the VB-Debug-Window
I greatly appreciate your message, I tried it but it doesn't print anything here:
Debug.Print WV.jsRun("myFunc")
I solved it this way but I don't consider it to be the most effective.
Code:command1_click()
script = "var divsListAds = document.querySelectorAll('.mt-ListAds');" & vbCrLf & _
"var hrefArray = [];" & vbCrLf & _
"divsListAds.forEach(function(div) {" & vbCrLf & _
"var enlaces = div.querySelectorAll('a');" & vbCrLf & _
"enlaces.forEach(function(enlace) {" & vbCrLf & _
"hrefArray.push(enlace.getAttribute('href'));" & vbCrLf & _
"});" & vbCrLf & _
"});" & vbCrLf & _
"var hrefArrayString = hrefArray.join('\n');" & vbCrLf & _
"navigator.clipboard.writeText(hrefArrayString).then(function() {" & vbCrLf & _
" window.chrome.webview.postMessage('Copiado al portapapeles');" & vbCrLf & _
"});"
WV.ExecuteScript script
end sub
I have the following code which works perfectly for me if I set breakpoints to validate the process, working perfectly this way, but if I remove the breakpoints and allow all the code to be processed, the system crashes. How could I solve it?
This information extraction is executed from a loop for which it loads a website in for and loads the data to the text boxes
Code:dim nextdata as boolean
private sub command1_click()
for a=1 to 2
WV.Navigate pagetoloader & "/" & a
Do
DoEvents
Loop Until nextdata = True
nextdata = False
next
end sub
Code:Private Sub WV_DocumentComplete()
if nextdata=true then
script="xxxxxx"
WV.ExecuteScript script
text1=Here I stored the variable from script in a textbox which was copied directly from the clipboard
sleep 500
script2="xxxxxx"
WV.ExecuteScript script2
text2=Here I stored the variable from script in a textbox which was copied directly from the clipboard
sleep 500
script3="xxxxxx"
WV.ExecuteScript script3
text3=Here I stored the variable from script in a textbox which was copied directly from the clipboard
sleep 500
nextdata=true
end if
end sub
The execution of the scripts are applied to each of the pages loaded in WV.Navigate pagetoloader & "/" & a
By-passing captchas is not a topic that we allow on VBForums. Please do not discuss this topic any further.
I have the next element is a website.
Code:<div class="mt-ListPagination"><ul class="sui-MoleculePagination"><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=4" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--empty sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-leftIcon"><span class="sui-AtomIcon sui-AtomIcon--small sui-AtomIcon--currentColor"><span class="sui-AtomIcon sui-AtomIcon--small sui-AtomIcon--currentColor" svgclass="mt-ListPagination-icon"><span><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.293 11.707c0-.256.098-.512.293-.707l6-6L15 6.414l-5.293 5.293L15 17l-1.414 1.414-6-6a.997.997 0 0 1-.293-.707"></path></svg></span></span></span></span><span class="sui-AtomButton-content"></span></span></a></li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds[0]=4&ModelIds[0]=0&Versions[0]=" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content">1</span></span></a></li><li class="sui-MoleculePagination-divider">···</li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=4" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content">4</span></span></a></li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=5" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--solid sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content">5</span></span></a></li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=6" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content">6</span></span></a></li><li class="sui-MoleculePagination-divider">···</li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=257" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content">257</span></span></a></li><li class="sui-MoleculePagination-item"><a href="/segunda-mano/?st=2&MakeIds%5B0%5D=4&ModelIds%5B0%5D=0&Versions%5B0%5D=&pg=6" shape="circular" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--outline sui-AtomButton--center sui-AtomButton--small sui-AtomButton--link sui-AtomButton--empty sui-AtomButton--circular"><span class="sui-AtomButton-inner"><span class="sui-AtomButton-content"></span><span class="sui-AtomButton-rightIcon"><span class="sui-AtomIcon sui-AtomIcon--small sui-AtomIcon--currentColor"><span class="sui-AtomIcon sui-AtomIcon--small sui-AtomIcon--currentColor" svgclass="mt-ListPagination-icon"><span><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M16 11.707a.997.997 0 0 0-.293-.707l-6-6-1.414 1.414 5.293 5.293L8.293 17l1.414 1.414 6-6a.997.997 0 0 0 .293-.707"></path></svg></span></span></span></span></span></a></li></ul></div>
I have tried clicking on the last element found within it (next page).
but I don't have an answer to it, what am I doing wrong?
example 1
Code:Dim script As String
script = "var paginationItems = document.querySelectorAll('.mt-ListPagination .sui-MoleculePagination-item');" & vbCrLf & _
"var ultimoItem = paginationItems[paginationItems.length - 1];" & vbCrLf & _
"if (ultimoItem) {" & vbCrLf & _
" ultimoItem.click();" & vbCrLf & _
"}"
WV.ExecuteScript script
example 2
Code:Dim script As String
script = "var ultimoItem = document.querySelector('.mt-ListPagination .sui-MoleculePagination-item:last-child');" & vbCrLf & _
"if (ultimoItem) {" & vbCrLf & _
" ultimoItem.click();" & vbCrLf & _
"}"
WV.ExecuteScript script
example 3
Code:Dim script As String
script = "var ultimoItem = document.querySelector('.mt-ListPagination .sui-MoleculePagination-item:last-child');" & vbCrLf & _
"if (ultimoItem) {" & vbCrLf & _
" var eventoClick = document.createEvent('MouseEvents');" & vbCrLf & _
" eventoClick.initEvent('click', true, true);" & vbCrLf & _
" ultimoItem.dispatchEvent(eventoClick);" & vbCrLf & _
"}"
WV.ExecuteScript script
example 4
Code:Dim script As String
script = "var ultimoItem = document.querySelector('.mt-ListPagination .sui-MoleculePagination-item:last-child');" & vbCrLf & _
"if (ultimoItem) {" & vbCrLf & _
" ultimoItem.scrollIntoView();" & vbCrLf & _
" setTimeout(function() {" & vbCrLf & _
" var eventoClick = document.createEvent('MouseEvents');" & vbCrLf & _
" eventoClick.initEvent('click', true, true);" & vbCrLf & _
" ultimoItem.dispatchEvent(eventoClick);" & vbCrLf & _
" }, 500);" & vbCrLf & _
"}"
WV.ExecuteScript script
Hello Olaf,
In the BindTo function, entering a command in additionalBrowserArguments (for example, "--lang=de") prevents the initialization of WebView2 with version 6.0.15 of RC6.
What am I doing wrong?
Thank you for your assistance.
Kind regards.
François
Just tested this here (on Win11) - and it works as it should...
(on the sole instance of the WV-Ctl I've created)...
IIRC, there was a problem sometime ago, where it was shown -
that *every* "follow-up" WV2-instance in a given Process -
needs to be started with the same commandline-params as the first created one...
I consider that a problem MS has to fix (if it's still there).
Olaf
Thank you Olaf,
You are the best!
It seems that all WV2s in a Windows session need to be initialized with the same parameters. I had two other applications running, different from the one I am developing, where a WV2 was initialized in French. It was then impossible to initialize in another language in the application I am developing. As soon as I closed these 2 applications, everything worked! This is a weird behavior from MS!
Thanks again for your quick response.
Best regards,
François
Ah, yes - that was the behaviour (which was discussed a few dozen entries back, here in this thread)...
and a solution for this was (IIRC), that the behaviour can be avoided, as long as a different UserFolder was given
(e.g. one Userfolder for french-users - and one for e.g. "--lang=de"-users on the same machine...).
Olaf
Hello Olaf,
Is it possible to parse with WebView2 not a site but a local html page ? I would like to identify some controls within that html file and to change their values. For example to change a checkbox from true to false. Thank you.