Not sure, whether the DPI-aware stuff is really related to the now "separated UserData-Folders per App-Exename" -
but version 6.0.15 is now online.
Olaf
Printable View
i downlaod new current version: 6.0.15, last updated: 2023-07-23
but i found can not run WV.jsProp. i change to 6.0.0.9 work ok.
the other question
the same code if i chang RC6.dl 6.0.0.9 to 6.0.15 ,MsgBox "Couldn't load regfree, will try with a registered version next..."Code:If Right$(App.Path, 1) <> "\" Then AppPath = AppPath & "\"
If App.LogMode Then '
On Error Resume Next
LoadLibraryW StrPtr(AppPath & DirectComDllRelPath)
Set New_c = GetInstanceEx(StrPtr(AppPath & RCDllRelPath), StrPtr("cConstructor"))
'Set New_c = GetInstanceEx(StrPtr(AppPath & "Bin\RC6.dll"), StrPtr("cConstructor"), True) '
If New_c Is Nothing Then MsgBox "Couldn't load regfree, will try with a registered version next..."
On Error GoTo 0
Else '
Set New_c = New cConstructor
End If
win7 32
Another issue is that playing online videos often results in buffering. And the same browser plays smoothly。How to solve it?thanks
Please give an example...
The Dll-binaries within your Bin-Folder have to match with the (registered) RC6-version you last compiled your executable with...
That's not really a problem of the wrapper... (the Browser-engine is from Google and MS) -
...just guessing here, ...
but perhaps a parallel installed MS-Edge/Chromium has different cache- or "virus-check-within-received stream-buffers" strategies at OS-level.
Olaf
i test your demo WebView2Demo.zip
i found not change red.but old vision work fineCode:and this shows, that the WV.jsProp("...") also works in Property-Let-Mode (at the left-hand-side)
btn1Caption = "Click Me..." 'change the Caption-String
WV.jsProp("document.getElementById('btn1').innerHTML") = btn1Caption 'and assign it to the Browser-Element as the new Caption via WV.jsProp() = ...
'just for fun, we can change the style of the btn1-Element to color='red' as well this way
WV.jsProp("document.getElementById('btn1').style.color") = "red"
This problem came up already a few times here (first time, I think - in #185):
https://www.vbforums.com/showthread....=1#post5580698
HTH
Olaf
thanks. jsprop This function is very convenient to use。now must change my code
This was 3 steps back, the problem with the dpi has been solved, but jsProp no longer works as before, everything changed, I still don't know how to fix it. before this worked for me WV.jsProp("map.getCenter().lat()") now not anymore!
Point #185 is not a solution, with WV.jsProp I could access a variable, if it worked fine, why did I change it?
Not "everything" - only jsProp shows a slightly different behaviour...
And as explained in #185 - I had no choice in the matter ...
(because newer Chromium-versions are now blocking eval() when used against some DOM-props).
So, my workaround around this chromium-issue with eval() was, to now parse a "given property-string" by hand (step by step) -
But note, that this workaround now only works on real property-sequences (and not "props with intermingled function-calls")...
So the string still can be nested with "dots" in-between properties - but no parentheses (no func-calls) are allowed in the string.
WV.jsProp("window.document.title") 'access on "pure" nested props still works
WV.jsProp("map.getCenter().lat()") '...whilst this doesn't anymore, because it contains ()-identifyable, intermingled function-calls
It's not that difficult, to write your own little helper-functions for communication with VB6,
as e.g. (after WV.Init was successful)...
Access then via WV.jsRun instead of WV.jsProp:Code:With New_c.StringBuilder 'js-helpers
.AddNL "function getMapCenter(){"
.AddNL " var c = map.getCenter()"
.AddNL " return [c.lat(), c.lon()].join(';')" 'returns two values (lat and lon) in a semicolon-separated string
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
Again, normally I try my very best, to not break existing functionality -Code:Debug.Print WV.jsRun("getMapCenter")
but in this case it was the "increased security" of the chromium-engine which "broke things" (on some sites).
Edit: What you can try, to simulate the "old behaviour" is, to run the javascript eval-function explicitely on your own like this:
... Debug.Print WV.jsRun("eval", "map.getCenter().lat()")
...meaning, that you could do a global replace of the term [ WV.jsProp( ] against [ WV.jsRun("eval", ]
This might work on some sites (which don't enforce a "restricted eval()", like the sites delivered from from google-servers for example).
Olaf
Thank you very much, this fixes it
Private Function WV_Eval(ByVal Value As String) As String
WV_Eval = WV.jsRun("eval", Value)
End Function
then replace all WV.jsProp by WV_Eval
jsProp,This function has a lot of problems and bugs,
Your reply doesn't mean anything other than misleading others, and it's not what this forum needs.
If you think jsProp has some problems, bring them up.
If you think jsProp has bugs, report them.
Based on my more than 10 years of experience with RC5/RC6, Olaf's code has very few bugs, and the quality of his code is at the top level even according to the standards of Commercial software.
more times,jsProp("document.title"),result is empty,and other js
WV_Eval replace to WV.jsProp maybe ok
execute WV.ExecuteScript "document.querySelector('#app > div > section > aside > span').click();" sometimes the webpage is not executed successfully. So I will modify it to
WV.ExecuteScript "document.querySelector('#app > div > section > aside > span').click();"
sleep 1000
WV.ExecuteScript "document.querySelector('#app > div > section > aside > span').click();"
sleep 1000
WV.ExecuteScript "document.querySelector('#app > div > section > aside > span').click();"
wo can tell me why? and hao can do well?
WV.ExecuteScript is working asynchronously.
And it should of course only be executed, when the Document was fully loaded
(meaning, the call should be executed either from within WV_DocumentCompleted,
or after that Event "came through").
And since modern pages are able to enhance their DOM even after DocumentCompleted was signaled,
it could very well be, that the span-element you want to click - simply "is not there yet".
Please wrap the Selector-query in a small function, which is able to test for "existence" (of a certain, element-addressing query-string).
E.g. you can add the 2 functions below via:
WV.AddScriptToExecuteOnDocumentCreated _
"function elementExists(sQuery){return document.querySelector(sQuery) ? true:false}" & vbCrLf & _
"function clickElement(sQuery){document.querySelector(sQuery).click()}"
And then test for existence via:
Const sQuery As String = "#app > div > section > aside > span"
If WV.jsRun("elementExists", sQuery) Then WV.jsRun("clickElement", sQuery) Else Debug.Print "Element doesn't exist yet..."
HTH
Olaf
There is no built-in method to store the entire contexts (html and images) of a webpage locally, is there?
I thought that since the data is already on my disk when I ask WebView2 to navigate to a certain page, I could perhaps extract the local data.
Please DON'T report bugs by a review, BUT HERE:
- https://github.com/vsDizzy/SaveAsMHT
######## Changelog #######
https://github.com/vsDizzy
CAN USE THIS?
Hello, I'm struggling to find the way to download a JSon file from an URL as string.
I need to download it using the WebView2 because I'm already using it to log-in to the site and to download some pages, and I need to send the session Cookie to be able to download the JSon, so since I was not able to get the Cookie with the method suggested here (because it appears that is no working now anymore, at least for me), I will have to get the JSon using the WebView2 itself and not by other download means.
I tried to get it with WV.jsProp("document.body.outerText") and it kinda worked but if the JSon is too large it gets cut.
Ideas?
"in-Page" (in-document) - http-requests (aka "Ajax-Requests") are traditionally done via the XMLHttpRequest object:
(which is quite similar in its usage, as the MS-WinHttp-COM-Object).
https://developer.mozilla.org/en-US/...XMLHttpRequest
In other words - don't use the Webviews "Navigate"-methods to retrieve JSON from a certain WebAPI -
use the XHR-Object instead "from the inside" of a loaded document (e.g. encapsulated in a little pre-added js-function).
Just tested this here - and it seems to work as described:
In case you're working against a "Google-URL" - these targets are known to torpedo the WebView2-COM-Object-supportCode:Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Set WV = New_c.WebView2(hWnd, 0)
End Sub
Private Sub WV_InitComplete()
WV.Navigate "https://vbForums.com", 0
End Sub
Private Sub WV_DocumentComplete()
Debug.Print WV.jsProp("document.cookie")
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
(the WV.AddObject-stuff ... which I need also on the inside of cWebView2, to interact with the VB-side).
E.g. when you navigate to "https:/google.com" - then WV.jsProp and WV.jsRun won't work properly.
Olaf
Hello Olaf. It is not Google, it is a private site.
Debug.Print WV.jsProp("document.cookie") returns an empty string.
Maybe that it is because it is an http site (not https)?
No, the reason in that case is, that document.cookie only returns "regular, non-HttpOnly-cookies"
(http-only-cookies are hidden and non-accessible via javascript)...
You can read about the different cookie-types here, for example:
https://dev.to/costamatheus97/battle...http-only-1n0a
As for: "How to get to those http-only-cookies without using javascript..." -
the WebView2 thankfully raises an Event we can use, where received resource-responses are reported
(including a param, which transports a http-response-headers JSON-collection)...
I've marked that Event in the following demo-code blue:
Edit: One can also use the somwhat more modern "Fetch-API" instead of the XMLHttpRequest-Object:Code:Private WithEvents WV As cWebView2
Private Sub Form_Load()
Set WV = New_c.WebView2(hWnd, 0)
End Sub
Private Sub WV_InitComplete()
WV.Navigate "http://SomeDomain.com", 0
End Sub
Private Sub WV_DocumentComplete()
Debug.Print WV.jsProp("document.cookie")
End Sub
Private Sub WV_WebResourceResponseReceived(ByVal ReqURI As String, ByVal ReqMethod As String, ByVal RespStatus As Long, ByVal RespReasonPhrase As String, ByVal RespHeaders As RC6.cCollection)
If RespHeaders.Exists("Set-Cookie") Then Debug.Print RespHeaders("Set-Cookie")
' Dim i As Long 'alternatively, one can enumerate all response-headers on the JSON-Collection
' For i = 0 To RespHeaders.Count - 1
' Debug.Print RespHeaders.KeyByIndex(i), RespHeaders.ItemByIndex(i)
' Next
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
https://developer.mozilla.org/en-US/...PI/Using_Fetch
The http-cookie should be transported back to the server automatically in these "internal requests" -
whereas "special tokens" have to be set manually in the clientside Headers of the request (in both cases)...
But just test it out in your own small js-functions (added in WV_Initcomplete via AddScriptToExecuteOnDocumentCreated)
HTH
Olaf
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.