-
Re: VB6 WebView2-Binding (Edge-Chromium)
excellent
I always use your tool (vbRichClient) , thank you for your hard work
WebView2 is a very good idea
The only problem is that I don't have permission to access and read files from the hard drive (allow file)
For example
In web page and javascript
HTML Code:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<script type="text/javascript">
video.load('Fire.mp4');
</script>
</body>
</html>
Error, this page says I receive
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Mojtaba
excellent
...don't have permission to access and read files from the hard drive...
The code below works for me (playing a local *.mp4 file):
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Dim VideoFile As String, sHTML As String, HtmlFile As String
VideoFile = "c:\temp\test.mp4"
HtmlFile = New_c.FSO.GetLocalAppDataPath & "\temp_vidplayer.html"
sHTML = "<!DOCTYPE html><html><head><meta http-equiv='X-UA-Compatible' content='IE=edge'></head>" & _
"<body><video controls width='100%' height='auto' src='" & VideoFile & "'/></body></html>"
New_c.FSO.WriteTextContent HtmlFile, sHTML, True
Me.Visible = True 'ensure Visibility before the Bind-call
Set WV = New_c.WebView2(Me.hWnd)
WV.Navigate HtmlFile
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
hello Olaf
have you had time to investigate the issue with the latest fixed versions of webview2?
Thanks in advance
Best regards
François
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
saturnian
...have you had time to investigate the issue with the latest fixed versions of webview2?
Yes, have done that just now ...
and I'm not able to reproduce the problems (here on a Win10 with all Updates).
Used the following relevant code-lines.
Code:
P = "c:\temp\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.70.x86"
If WV.BindTo(picWV.hWnd, 8, P, "c:\temp\WV2UserData") = 0 Then
MsgBox "couldn't initialize WebView-Binding": Exit Sub
End If
Like you, I've used an explicitly given "fixed-runtime-path" as well as a "local UserData-Path"...
What I took care of was the following:
- I've downloaded the x86-flagged, fixed runtime from the MS-site (it comes in a *.cab-file)
- FWIW, I've unpacked this *.cab with 7zip (and not the built-in Win10-CabViewer)
- placed the unpacked Folder in a Parent-Folder I have full write-rights on ("c:\temp\...")
- created a new, empty UserDirectory in "c:\temp\WV2UserData" (before trying the Bind-call)
Things to note (things of importance, regarding the error on your side):
- already mentioned, but make sure to use the 32bit-(x86)version of the fixed-runtime
- my "User-Directory" is not a sub-directory of the "fixed-runtime-folder"
- neither Directory is causing "potential File-Virtualization-issues" (due to placement in the C:\Programs\-Folder)
- neither Directory is provocing "treatment as an x64-Program" (due to placement in the C:\Programs\-Folder)
- Me.Caption = New_c.Version ...shows "6.0.12" (just make sure to report this "live", to rule out regfree-loading of older versions)
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
What I took care of was the following:
- I've downloaded the x86-flagged, fixed runtime from the MS-site (it comes in a *.cab-file)
- FWIW, I've unpacked this *.cab with 7zip (and not the built-in Win10-CabViewer)
- placed the unpacked Folder in a Parent-Folder I have full write-rights on ("c:\temp\...")
- created a new, empty UserDirectory in "c:\temp\WV2UserData" (before trying the Bind-call)
Things to note (things of importance, regarding the error on your side):
- already mentioned, but make sure to use the 32bit-(x86)version of the fixed-runtime
- my "User-Directory" is not a sub-directory of the "fixed-runtime-folder"
- neither Directory is causing "potential File-Virtualization-issues" (due to placement in the C:\Programs\-Folder)
- neither Directory is provocing "treatment as an x64-Program" (due to placement in the C:\Programs\-Folder)
- Me.Caption = New_c.Version ...shows "6.0.12" (just make sure to report this "live", to rule out regfree-loading of older versions)
HTH
Olaf
I checked all the previous items except:
Me.Caption = New_c.Version ...shows... ... ... "6.0.10" !
Because, on the site http://vbrichclient.com/ it is displayed:
Quote:
Downloads
The Base-Dlls of the current toolset (version 6) are contained in this minimum-package:
RC6BaseDlls.zip (~ 3.5MB, current version: 6.0.10, last updated: 2022-07-31 ... including SQLite-version: 3.39.2)
so I didn't think to download RC6BaseDlls.zip again ! I remained convinced that the current version was 6.0.10 !
I won't be fooled now ! ;)
Version 6.0.12 fixes all issues ! Thanks
François
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hi have nice day thanks for this complemente,
i have a simple question
i am try navigate to http://jsfiddle.net/qqzxtk67/
this fire new window
How i can manipulate this thanks?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
astronald
Not sure, what you mean exactly (with "manipulate this")...
What do you want to achieve in the end?
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Can your control make use of OnFrameLoad event?
I need to inject JS at this point of time.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Can your control make use of OnFrameLoad event?
I need to inject JS at this point of time.
Have not played around with iFrames so far (in the context of WV2 and the stuff i use it for currently) -
but the documentation says (about the AddScriptToExecuteOnDocumentCreated-method):
The injected script will apply to all future top level document and child frame navigations...
With that, you should be able to place dedicated js-functions and -variables (for use from within an iFrame),
without the need of "waiting for a FrameLoad-event".
If you're already using AddScriptToExecuteOnDocumentCreated -
can you post a short example, what you want to achieve - and where the problem comes in?
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I need to inject scripts to change the pages colors for handicapped users, and this is the only event where I can do it.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
I need to inject scripts to change the pages colors for handicapped users, and this is the only event where I can do it.
I'm quite sure, that AddScriptToExecuteOnDocumentCreated can accomplish what you want
(without using that event).
Please post some code-example.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
First of all, as written by me quite a few times in our forums in the past, I remain in awe of both your fabulous work and your fabulous heart. I am happy that I finally got time to dig into your vbRichClient-Framework, learning many aspects of it, slowly and steadily, since the past 2-3 weeks.
Thanks a TON to you, I learnt the "fundamentals" of 'Open Source' licenses for the first time, from your '_Library-Licenses.txt' file. My Hearty Thanks in TONs, time and again, to you and all the developers of all the "Open Source" libraries/tools.
Just thought of letting you know that some of the links (to the 'Open Source' libraries) in the aforesaid text file are not working now. For e.g., for LZ4, "http://cyan4973.github.io/lz4/" does not work now. As far as I have explored, "https://github.com/lz4/lz4" looks to be the correct page now. Similarly, "https://zlib.net/zlib_license.html" works for the latest license page of 'zlib' (and not http://www.gzip.org/zlib/zlib_license.html). You may anyway double-check on this from your side too because I am quite new to using "Open Source" libraries. I just felt that I should let you know my findings so that you can replace the non-working links with the right ones in the '_Library-Licenses.txt' file in the next release of vbRichClient-Framework, if at all my findings are correct. If my findings are not correct, kindly bear with me.
Well, the WebView2Loader.dll found in your latest "RC6BaseDlls.zip" package is 112KB (115, 128 bytes) with version number of 1.0.1462.37.
Specifically, with respect to the deployment of one's compiled application in a different system
--
Should I always use this '1.0.1462.37' version numbered WebView2Loader.dll only? (Presuming your cWebView2 makes calls specific to this DLL only)
(OR)
Can I use the latest WebView2Loader.dll also? The version number of the latest WebView2Loader.dll is "1.0.1587.40" as of today, as per https://www.nuget.org/packages/Microsoft.Web.WebView2, if I am right.
(OR)
Should I always use the latest WebView2Loader.dll only?
--
Thanks in TONs once again. I sometimes go silent thinking of the immense magnitude/depth of your work for this world society. God Bless you, olaf! God Bless All!
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
I noticed in https://www.cairographics.org/news/ that a new release of Cairo library has happened after quite a long gap of time. This news got me really excited thinking that this would mean that "perhaps" you have now started working on releasing the next RC6 build covering all the new features of Cairo library. If so, then my wishes in advance to you for the new/updated release of RC6.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
And, while I await with patience your answer to my query regarding 'WebView2Loader.dll' in post no. 252, dear Olaf,
Coming to 'Cairo', I have a small query. How to include blur also to a text with shadow? For instance, in CSS, the 'text-shadow' property has 'blur radius' too (ref: https://developer.mozilla.org/en-US/...SS/text-shadow)
I understood by reading some materials in the net that Cairo does not provide the 'blur' feature on text shadows straightaway but it can be achieved by writing a suitable routine in c++. I am not comfortable in c++ coding though.
I do remember reading (a week back or so) about 'Gaussian blur' in your 'Cairo' tutorials AND/OR in some of your forum messages but I saw 'Gaussian blur' applied to images only, if my understanding was right.
Honestly, I have not found time yet to go through all your excellent 'Cairo' tutorials. But, I do have "sincerely" gone through some of them and learnt a good lot about text rendering on paths. If indeed 'blur on text shadow' is already covered by you in any of your tutorials OR in any of your forum messages, then kindly intimate me the same and I shall go through them. Or, if such tutorials/messages do not exist yet, then, if at all and when your time permits, kindly provide me a code snippet which would "exactly" mimic what the following CSS would achieve when applied for any text.
--
"text-shadow: h-offset v-offset blur-radius color;"
--
I take this opportunity to once again thank you for both your work and your heart. God Bless you! God Bless ALL!
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Not sure, what you mean exactly (with "manipulate this")...
What do you want to achieve in the end?
Olaf
Thanks i want Execute javascript on new windows and read elements
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
Can I use the latest WebView2Loader.dll also?
You can, but you don't have to...
WebView2Loader.dll is just a small "communication-vehicle" between your App -
and the "rolling, evergreen" Edge/Chromium-releases MS performs under the covers of your OS automatically.
If there's a new feature I expose in new RC6.cWebView2-releases
(using potentially "new, extended communication-interfaces" of the WebView2Loader),
then I'll deliver the RC6-bundle with that new(er) WebView2Loader.dll as well, of course.
Thanks for the FOSS-Link-updates - I've included them now in _LibraryLicenses.txt.
As for "plain cairo-questions" ... it's better to ask them in the normal Forum in the future -
(to keep this thread here related to the RC6.cWebView2-class and its usage).
But here's a little helper-function for "shadowed text-output":
Code:
Option Explicit
Private Sub Form_Load()
Dim CC As cCairoContext
Set CC = Cairo.CreateSurface(800, 600).CreateContext 'create the "main"-Surface-context
CC.Paint 1, Cairo.CreateSolidPatternLng(&H333333) 'ensures a dark-grey background
CC.SelectFont "Times New Roman", 22, vbGreen, False, True
DrawTextWithShadowOn CC, 10, 10, 300, 50, "Some shadowed Text", 4, vbYellow, 1, 1
Set Picture = CC.Surface.Picture
End Sub
Sub DrawTextWithShadowOn(CC As cCairoContext, x, y, dx, dy, Text As String, _
Optional ByVal R& = 3, Optional ByVal ShadowColor&, Optional ByVal xOffs#, Optional ByVal yOffs#)
CC.Save
CC.TranslateDrawings x, y
CC.PushGroup CAIRO_CONTENT_COLOR_ALPHA, 0, 0, dx, dy
CC.DrawText 0, 0, dx, dy, Text, True 'render the text within a Push/Pop-sequence
Dim Pat As cCairoPattern: Set Pat = CC.PopGroup(True) 'retrieve the output via Pop (in a Pattern-Obj)
With Cairo.CreateSurface(dx, dy).CreateContext 'create a temp-surface in the dimensions of the Text-Rect
.Paint 1, Pat '"play back" the pattern from the above "Push/Pop-Operation" on this temp-Surface
'and what follows now, is simply two calls (1. rendering the blurred-temp-surface, and 2. rendering the unblurred srf on top)
CC.RenderSurfaceContent .Surface.GaussianBlur(R / 2, R, True, ShadowColor), xOffs - R, yOffs - R
CC.RenderSurfaceContent .Surface, 0, 0
End With
CC.Restore
End Sub
As for upgrading to new(er) Cairo-Releases... the current Cairo.Version 1.17.02
(which includes some "cherry-picks" from later releases),
it seems to work nicely and stable (without mem-leaks) - so unless there's some new features which are a "must have",
I'm not planning on updating to later versions anytime soon.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
You can, but you don't have to...
... .. .
But here's a little helper-function for "shadowed text-output":
.. .. .
Olaf
Thanks a LOT, Olaf. As ever, you are so helpful with all the detailed information regarding WebView2Loader.dll, etc.
The helper function worked like a charm to create "text shadows with blur"! The best way to see its beauty in action was to change the various parameters (color, offsets, etc.) and see the corresponding effects. It was wonderful. Really. I will now try to take time to understand more of Gaussian Blur.
And, I am really sorry about posting my cairo-related query in this "RC6 cWebView2"-related thread. Only 5 minutes after posting it, I suddenly realised my mistake. I will be careful in the future. Sorry again.
Kindest Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I have uploaded the script here:
https://drive.google.com/file/d/1ovs...ew?usp=sharing
When you inject the entire text and then navigate to web.whatsapp.com, the selected chat will be blue.
That is how you can test if it worked.
Thank you!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I have tried it like this:
Code:
Private Sub Form_Load()
Visible = True '<- it's important, that the hosting TopLevel-Form is visible...
'...(and thus the Child-PicBox indirectly as well) - before we Bind the PicBox to the WebView
Set WV = New_c.WebView2 'create the instance
If WV.BindTo(picWV.hWnd) = 0 Then MsgBox "couldn't initialize WebView-Binding": Exit Sub
' Set WV = New_c.WebView2(picWV.hWnd) 'create the instance
' If WV Is Nothing Then MsgBox "couldn't initialize WebView-Binding": Exit Sub
LocalWebViewInit 'initialize the WebView for local usage here in our Form
Dim sWA$
sWA = GetText("c:\users\myuser\desktop\whatsapp.txt")
WV.AddScriptToExecuteOnDocumentCreated sWA
End Sub
Private Sub cmdNavigate_Click()
WV.Navigate "https://web.whatsapp.com"
End Sub
Private Function GetText(ByVal u As String) As String
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strm As Scripting.TextStream
With fso
Set strm = .OpenTextFile(u, ForReading, False, TristateTrue)
Do Until strm.AtEndOfStream
GetText = strm.ReadAll
Loop
strm.Close
End With
strm.Close
End Function
But that doesn't work. The chat should highlighted with blue color, but it's not.
Also, calling the JS functions that I added does not work.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
...calling the JS functions that I added does not work.
There is an error in your larger js-Code-File:
Code:
const setupWhatsapp = () => {
alert('before highlighter');
highlighter.initHighlighting();
alert('after highlighter); // <- missing string-quote-char
overrideSelectedItemBackgroundColor(); // <- therefore, this line will not execute
};
BTW, do you get any of the "other alerts" you've placed there?
You could also place this little EventHandler-snippet via AddScriptOnDocumentCreated (in case you know the iFrame-ID):
Code:
document.getElementById('my_iframe_id').onload = function() {
// load your extra-modules (including your inits and color-replacements) here
}
Cannot further play around with this myself, because I have no "whatsapp"-account.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
astronald
...i want Execute javascript on new windows and read elements
Not sure, whether the following example does what you had in mind -
but the demo below will suppress the "WV2-built-in default-BrowserWindow-Popups",
and will simply create additional VB-Form-instances instead (each using their own internal WV-Instance of course).
Code:
Option Explicit
Public WithEvents WV As cWebView2, WithEvents tmrNewWindow As cTimer
Private Sub Form_Load()
Me.Visible = True 'ensure Visibility before the Bind-call
Set WV = New_c.WebView2(Me.hWnd) 'does an implicit bind-call (within this constructor-method)
WV.AddScriptToExecuteOnDocumentCreated "function openPopup(uri){window.open(uri,'','width=800,height=600')}"
If Forms.Count = 1 Then 'it's the first instance of this Form-Type (so we show an entry-demo-page, based on our own html-text)
Const btnDef$ = "<input value='show new window' type='button' on" & "click='openPopup(""https://google.com"")'>"
WV.NavigateToString btnDef
End If
WV.SyncSizeToHostWindow
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Private Sub WV_NewWindowRequested(ByVal IsUserInitiated As Boolean, IsHandled As Boolean, ByVal URI As String, NewWindowFeatures As RC6.cCollection)
IsHandled = True '<- suppress the Browser-Controls default-handler
NewWindowFeatures.Prop("URI") = URI 'let's enhance the features-(JSON)collection about the URI-Property
Set tmrNewWindow = New_c.Timer(10, True, NewWindowFeatures) 'and now buffer the features-(JSON)collection in the timer-tag, to be able to leave here as soon as possible for the sake of "non-blocking"
End Sub
Private Sub tmrNewWindow_Timer() 'this decoupling oneshot-timer only fires in case of a new Window-Request
ShowNewWindow tmrNewWindow.Tag 'pass the JSON-collection along (from the timers Variant-Typed Tag-Property)
End Sub
Public Sub ShowNewWindow(NewWindowFeatures As cCollection)
Set tmrNewWindow = Nothing 'we can safely destroy the "one-shot"-timerInstance now (since it delivered its Tag-Data)
Dim F As New Form1
F.Show , Me 'let's show the new form (after setting its feature-Collection above)
With NewWindowFeatures
If .Prop("HasPosition") Then F.Move .Prop("Left") * Screen.TwipsPerPixelX, _
.Prop("Top") * Screen.TwipsPerPixelY
If .Prop("HasSize") Then F.Move F.Left, F.Top, .Prop("Width") * Screen.TwipsPerPixelX, _
.Prop("Height") * Screen.TwipsPerPixelY
F.Caption = .Prop("URI")
F.WV.Navigate .Prop("URI")
Debug.Print .SerializeToJSONString '(just to show, what else is contained in the features-collection)
End With
End Sub
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
-
Re: VB6 WebView2-Binding (Edge-Chromium)
How could I call this js function using WV2?
Dim c As cStringBuilder
Set c = New cStringBuilder
c.Append "function GetScrollPosX()"
c.Append "{"
c.Append " return (Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));"
c.Append "}"
-
Re: VB6 WebView2-Binding (Edge-Chromium)
And I have to say Congralatutions and thank you. I use your dhRichClient in all my apps. I could not live without it. And I hate .NET. The IDE is so slow that I just can't use it. Really, I need 5x as much time just because it responds so slowly and has such bad Edit and Continue capabilities. I am so much quicker with VB6. I use .NET for simpler projects only or for Unity which itself is slow to work with. But for quick typing, nothing is better than VB6.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
How could I call this js function using WV2?
Dim c As cStringBuilder
Set c = New cStringBuilder
c.Append "function GetScrollPosX()"
c.Append "{"
c.Append " return (Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));"
c.Append "}"
I'd use the StringBuilder via New_c constructor (for better "regfree-mode-compatibility"):
Code:
With New_c.StringBuilder
.AddNL "function GetScrollPosX(){"
.AddNL " return Math.max(document.body.scrollLeft,document.documentElement.scrollLeft)"
.AddNL "}"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
So, the adding of this function-code-snippet happens in the line before the "End With"-destruction of the StringBuilder.
The functioin-call itself can then be done from the VB6-side by specifying the funcName (without parens) in WV.jsRun:
Debug.Print WV.jsRun("GetScrollPosX") 'optional Parameter-Passing via ParamArray is possible
And JFTR, also "pure-property-access" is possible, without any "extra-function-definition" -
(even for "nested-props", as long as there's "only dots and no parentheses" in the prop-hierarchy-string):
Debug.Print WV.jsProp("document.body.scrollLeft")
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
How do I get the currently shown URL, please?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Is there perhaps a way to include an ad blocker?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I am trying to run this JS code to scroll the window down:
WV.jsRunAsync "window.scrollBy({ top: 300, behavior: "smooth" });"
It does not work. What am I doing wrong?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
WV.jsRunAsync "window.scrollBy({ top: 300, behavior: "smooth" });"
It does not work. What am I doing wrong?
What you're doing wrong is, to not read the Parameter-Names in the Intellisense-Popups... ;)
Both, WV.jsRun and WV.jsRunAsync expect a "function-name" in the first argument.
So, the easiest way is, to "wrap the little code-block" in your own user-function - as e.g.:
WV.AddScriptToExecuteOnDocumentCreated "function scrollSmoothlyBy(x,y){ window.scrollBy({left:x, top:y, behavior:'smooth'}) }"
You can then later call it e.g. this way (passing the x,y arguments after the function-name):
WV.jsRunAsync "scrollSmoothlyBy", 5, 15
As for extensions like AdBlock... those were not supported the last time I've looked...
Here's a posting on stack-overflow: https://stackoverflow.com/questions/...on-on-webview2
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Can I get the current URL somehow?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Would you recommend to add all the functions that I need for example at program start up, correct?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I am adding this code via "wv.AddSCriptToExecuteOnDocumentCreated" when initiating WV:
Code:
function pSetFocus()
{
alert('focus');
var element = document.querySelector("*[autofocus]");
if (element)
{
}
else
{
element = document.querySelector("form input:not([type=hidden])");
}
if (element)
{
}
else
{
element = document.querySelector("input#search");
}
if (element)
{
}
else
{
element = document.querySelector("input#search.ytd-searchbox");
}
if (element)
{
}
else
{
}
if (element)
{
var sType=element.type;
if (sType != "email")
{
element.selectionStart = element.selectionEnd = element.value.length;
}
element.focus();
var y = element.getBoundingClientRect().top + window.scrollY;
window.scroll(
{
top: y,
behavior: "smooth"
});
}
Then, when I want to set the focus to the first input element, I call:
Code:
WV.SetFocus FocusReason_PROGRAMMATIC
WV.jsRunAsync "pSetFocus();"
It doesn't have any effect.
What am I doing wrong?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Then, when I want to set the focus to the first input element, I call:
Code:
WV.SetFocus FocusReason_PROGRAMMATIC
WV.jsRunAsync "pSetFocus();"
It doesn't have any effect.
What am I doing wrong?
Olaf just said that it expects a function name so I'd expect that your code should be this instead:-
Code:
WV.jsRunAsync "pSetFocus"
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I have tried that as well, it doesn't work.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Ah well that's all I got. I have no experience using WebView. Perhaps someone else can try their hand at the problem.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I was stupid. My JS code was faulty. I've been using a different browser before, and it was more foregiving.
Once I fixed it, it went fine!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Would you recommend to add all the functions that I need for example at program start up, correct?
Of course... and you don't have to call: WV.AddScriptToExecuteOnDocumentCreated
for every little function-snippet separately (after the Bind-call was successful).
Easier would be, when you place all your helper-functions in a single "MyHelpers.js"-file...
and then use an UTF8-capable TextFile-ReadHelper to load them in a single line of code:
WV.AddSCriptToExecuteOnDocumentCreated New_c.FSO.ReadTextContent("MyHelpers.js", False, CP_UTF8)
And when you use a decent TextEditor like VSCode to edit this js-File, then you'd also produce less "basic typos with js-syntax",
since this Editor will give you nice "visual hints" about "missing parentheses" or "missing quotechars around strings".
As for "how to get the current Document-Title or Document-URL" -
there's already two Properties in place on the cWebView2-class:
- WV.DocumentURL
- WV.DocumentTitle
Please do some "basic investigations" on the library (RC6) or current Class (RC.cWebView2) first,
before you start working on something concrete... (e.g.via ObjectExplorer, reachable via <F2>-Key).
There's only about 50 Methods, Properties and Events behind the WV2-class -
(and half of them are "IsThatEnabled" or "AreTheseAllowed" basic boolean-Props).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
GetEdgeWebViewInfo:
---------------------------
Microsoft Edge WebView2 Runtime,Version:110.0.1587.63
---------------------------
Code:
Function GetEdgeWebViewInfo(Optional CheckX64 As Boolean) As String
On Error Resume Next
Dim WshShell As Object
Dim WebView2_Version As String, WebView2_Name As String
Dim RegPath As String
Set WshShell = CreateObject("Wscript.Shell")
RegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\" & IIf(CheckX64, "WOW6432Node\", "") & "Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\"
'InputBox "", "", RegPath
WebView2_Name = WshShell.RegRead(RegPath & "name")
WebView2_Version = WshShell.RegRead(RegPath & "PV")
GetEdgeWebViewInfo = WebView2_Name & IIf(WebView2_Version <> "", ",Version:" & WebView2_Version, "")
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Not sure, whether the following example does what you had in mind -
but the demo below will suppress the "WV2-built-in default-BrowserWindow-Popups",
and will simply create additional VB-Form-instances instead (each using their own internal WV-Instance of course).
Code:
Option Explicit
Public WithEvents WV As cWebView2, WithEvents tmrNewWindow As cTimer
Public Sub ShowNewWindow(NewWindowFeatures As cCollection)
Set tmrNewWindow = Nothing 'we can safely destroy the "one-shot"-timerInstance now (since it delivered its Tag-Data)
*************
F.Caption = .Prop("URI")
F.WV.Navigate .Prop("URI")
Debug.Print .SerializeToJSONString '(just to show, what else is contained in the features-collection)
End With
End Sub
HTH
Olaf
if new webview by post, how to do?not only by url
F.WV.Navigate .Prop("URI")
maybe need like webbrowser
postdata="user=abcd&pass=aaabbb"
httpheadStr="ref=www.baidu.com" & vbcrlf & "header2key=333"
webbrowser1.Navigate url,httpheadStr,postdata
in java,new webview only need input webview ID,IT WILL AUTO DO POSTdada or http header info.
Code:
Function WebPost(url As String, PostInfo As String, Web1 As WebBrowser, Optional ref As String, Optional cookie As String)
'[mycode_id:1274],edittime:2011-5-10 上午 12:26:45
On Error Resume Next
ReDim AByte(0) As Byte
PackBytes AByte(), PostInfo
Dim vPost As Variant
vPost = AByte ' Assign the byte array to a VARIANT
Dim vHeaders As Variant
vHeaders = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)
If ref <> "" Then vHeaders = vHeaders & "Referer:" + ref & vbCrLf
If cookie <> "" Then vHeaders = vHeaders & "Cookie:" + cookie & vbCrLf
Web1.Navigate url, , , vPost, vHeaders
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Win10 has direct support for unpacking of *.cab-Archives -
otherwise use 7zip?
In any case, you should end up with an unpacked Folder, named:
..\Microsoft.WebView2.FixedVersionRuntime.107.0.1418.62.x86
somewhere on your local harddisk.
Now move that whole Folder to a place you prefer in your filesystem -
and then point the 3rd Param of the BindTo-method to that Directory-Path-(String).
Olaf
Code:
OK = Web1.BindTo(Me.hWnd, , App.Path & "\WebviewSdk\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x86") <> 0
'OK = Web1.BindTo(Me.hWnd, , App.Path & "\WebviewSdk\Microsoft.WebView2.FixedVersionRuntime.110.0.1587.63.x86") <> 0
msgbox "web1.UserAgent=" & WV.UserAgent
msgbox "navigator.appVersion=" & Web1.jsProp("navigator.appVersion")
view webview version online:
https://ie.icoa.cn/
====================
Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x86.cab
内核版本 (Version) WebKit 537.36 Chrome 109.0.0.0
完整代码 (UA)
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.78
====================
Microsoft.WebView2.FixedVersionRuntime.110.0.1587.63.x86.cab:
内核版本 (Version) WebKit 537.36 Chrome 110.0.0.0
完整代码 (UA)
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.63
-
1 Attachment(s)
Re: VB6 WebView2-Binding (Edge-Chromium)
If have a such website, everybody can add modify complement perfect knowledge base together, write example code, like this convenient.
Do you have a help file? If you can control OCX or COM DLL, Windows API as a database knowledge base, list all properties, methods, events, constant values, optional parameters, meaning. An example call for each method. Then automatically generated HTM format help file is very convenient, you need a tool like this. Rc6. CWEBVIEW2, there are 70 or so method properties, if you can make a complete example, including all the method calls is perfect, in the code marked: ' 1/AcceleratorKeyPressed/event' 2/AddObject/method' 3/AddScriptToExecuteOnDocumentCreated such a workload is undoubtedly very large, most people use only a small amount of functionality. If do a such general control knowledge base software, Windows API, SQLITE3.0. DLL, VBA Excel. Application and other uses of the knowledge base management, use should be very convenient.
Attachment 187121
-
Re: VB6 WebView2-Binding (Edge-Chromium)
1)
How would I do this in WebView2, please?
cefSetting.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-required");
2)
How could I disable opening new windows?
3)
How could I disable that users can right-click the browser to invoke for example "Save as...", "Inspect", etc.?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
3)
How could I disable that users can right-click the browser to invoke for example "Save as...", "Inspect", etc.?
Does setting the WebView2 AreDefaultContextMenusEnabled property to False prevent the menu from appearing?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
2)
How could I disable opening new windows?
Does this work?
Code:
Private Sub WV_NewWindowRequested(ByVal IsUserInitiated As Boolean, IsHandled As Boolean, ByVal URI As String, NewWindowFeatures As RC6.cCollection)
IsHandled = True '<- suppress the Browser-Controls default-handler
End Sub
See this post: https://www.vbforums.com/showthread....=1#post5597387
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
1) How would I do this in WebView2, please?
cefSetting.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-required");
Chromium CommandLine-switches can be passed in one of the optional Arguments of the "Bind-call"...
(and were discussed more than once in this threads history)... ;)
WV.BindTo(hWnd, , , ,"--autoplay-policy=no-user-gesture-required")
Here's the Link again, which describes them:
https://peter.sh/experiments/chromiu...utoplay-policy
Olaf
-
1 Attachment(s)
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Chromium CommandLine-switches can be passed in one of the optional Arguments of the "Bind-call"...
(and were discussed more than once in this threads history)... ;)
WV.BindTo(hWnd, , , ,"--autoplay-policy=no-user-gesture-required")
Here's the Link again, which describes them:
https://peter.sh/experiments/chromiu...utoplay-policy
Olaf
// and were discussed more than once in this thread's history //
Yes indeed, My Dear Olaf. And using this particular tip led me to have moments of great joy once I discovered that Spell-Checker (for languages other than the default English) can also be invoked via the Bind-Call. I had to try for quite some time to get it right (I almost decided to write here and ask you) but eventually when I got it working, that was such a joy (Word suggestions for misspelt words are also shown!!!). The joy you are giving to so many (few known to you, millions unknown to you) in this world society must be getting registered constantly in the Divine books, I firmly believe. May be it is possible to invoke the translator too! I am yet to explore. If possible and if you know the argument(s) for the same already, kindly let me know. Thanks in advance.
Well, coming to the Bind-Call (e.g. "--accept-lang=en-US,en,fr" wherein I have included 'fr' also to be considered for spellchecking), I wish to know the following:
1. For the spellchecker/word-suggestions to function (for any included language), does MS always send the words typed to its servers, to get the required results? Or, is it always done locally after downloading the required language dictionaries once (perhaps updated occasionally too) to user's system? How "exactly" is this spell-checker/word-suggestions functionality effected by MS in WebView2? Will be helpful to share this info with users if such info is "concretely" known.
2. Is it possible to access the word suggestions programmatically and show it in my own separate list?. For instance, when I typed "SpellChecker", the spellchecker engine identifies it as misspelt and when I right click on it, the resultant context menu is as in the picture below. Is it possible for me to programmatically access these three word suggestions (Spellchecker, Spellcheckers, Spell-checker) and show them alone in my own list on right-clicking (OR any other way, so that the default right-click menu gets displayed as usual)?
https://www.vbforums.com/image/png;b...AASUVORK5CYII=
Attachment 187181
3. I noticed that if I use more than one reference (say WV and WV2) to cWebView2 in my program, then while binding, I needed to "exactly" give the same "--accept-lang" argument in both Bindings. i.e. it had to be as follows:
--
If WV.BindTo(picWV.hWnd, TIME_TO_WAIT_m, , , "--accept-lang=en-US,en,fr") = 0
If WV2.BindTo(picWV2.hWnd, TIME_TO_WAIT_m, , , "--accept-lang=en-US,en,fr") = 0
--
Otherwise, the 2nd binding won't happen. I have no problems keeping the same argument in both bind calls, but I feel that perhaps I am doing a mistake and there possibly is a way by which I can pass different "--accept-lang" argument in each of the WV bind calls. May be the correct argument is different from "--accept-lang" itself for SpellChecker?
I searched in this thread right now in each of it's pages and did not find the above matters (with respect to "accept-lang") discussed directly, except one indirect reference to "accept-lang" in the 5th page [xhr.setRequestHeader('Accept-Language', 'en-US,en;q=0.9';]. Hence, I decided to go ahead writing&asking about the above matters via this post. Sure I have done the right thing. In case all of the above have been already discussed (in this thread or elsewhere), then sorry about it. Kindly point me to those messages (here or elsewhere), Olaf. Thank you once again, Olaf, from the bottom of my heart. God Bless you! God Bless ALL!
Kind Regards.
Edited:
- just corrected "picWV" to "picWV2" in the "WV2.BindTo" line.
- just a while ago noticed that the picture I inserted is missing. Have inserted it again.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I would like to access certain elements of a webpage like links, buttons, etc.
I want to use JavaScript to do that.
I have uploaded my script here: https://drive.google.com/file/d/1nfC...usp=share_link
First, I need to call grid_ensureHotSpotIds to create these elements.
I know that this question is relatively specific to JS, but can anybody tell me anyways how I would then access these hotspots from VB6?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
...I need to call grid_ensureHotSpotIds to create these elements.
From what's defined in your js-code, I only see 3 Functions, defined on the (global) window-object:
window._grid_ensureHotSpotIds
window._grid_getHotSpots
window._grid_getFocusedElementHotSpots
Note the leading underscore of these 3 functions (which you'd have to specify in the function-name-arg of WV.jsRun )
Here's an example:
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True 'ensure Visibility before the Bind-call
Set WV = New_c.WebView2(Me.hWnd)
WV.AddScriptToExecuteOnDocumentCreated "window._foo = function(){alert('bar')}"
WV.NavigateToString "<p>dummy-content, nothing to see here...</p>" 'ensure simple "document-content"
WV.jsRun "window._foo" 'should show an alert('bar')-popup
WV.jsRun "_foo" '... should show the same (the preceding window. is optional)
End Sub
Quote:
Originally Posted by
tmighty2
...how I would then access these hotspots from VB6?
Just call the functions directly via WV.jsRun (if they are directly callable, due to definition on the Window-Object)...
Or add little wrapper-functions via WV.AddScriptToExec... (to indirectly call stuff which is deeper hidden behind other objects)
In either case, please return either "simple types" from these functions (Strings, or Numbers, or Booleans or Nulls) -
or (in case you want to return js-Arrays or js-Objects) return them this way:
return JSON.stringify(MyArray_Or_MyObject)
A function which returns such stringified JSON, can be called this way from VB (auto-decoding the JSON-string already):
Dim JSON as cCollection
Set JSON = New_c.JSONDecodeToCollection( WV.jsRun("myfunc", P1, P2) )
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The following global EventListener on the document works perfectly for the target element 'abc'.
Code:
With New_c.StringBuilder
.Add "document.addEventListener('change', function(e) {"
.Add " e = e||window.event;"
.Add " if (e.target.id == 'abc') {"
.Add " vbH().RaiseMessageEvent('abcChange', e.target.value)"
.Add " };"
.Add "}, false);"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
But, the same EventListener when applied specifically to the target element 'abc' (as follows) does not work (i.e. the 'abcChange' event is not raised).
Code:
WV.AddScriptToExecuteOnDocumentCreated "var abc = document.getElementById('abc'); abc.addEventListener('change', function(event) {vbH().RaiseMessageEvent('abcChange', abc.value);},false);"
I think the 'abc' element is not yet loaded when the above script is added. Am I right?
Of course the above line (modified suitably as follows) and included in the <script> section of the html file works perfectly.
Code:
var abc = document.getElementById('abc'); abc.addEventListener('change', function(event) {alert (abc.value + ' eureka');},false);
So, to make the above line work through my application itself, I added the following line in the "WV_DocumentComplete" event and it works but it takes effect after the 2nd 'change' event onwards only. First time when there is change in the 'abc' element, the 'abcChange' event is not raised.
Code:
WV.ExecuteScript "var abc = document.getElementById('abc'); abc.addEventListener('change', function(event) {vbH().RaiseMessageEvent('abcChange', abc.value);},false);"
So, what is the right way to proceed if I need to add an EventListener to a specific target element alone? Can somebody kindly educate and help me out? Please.
Kind regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
In order that the scripts added to a WV (via functions like AddScriptToExecuteOnDocumentCreated, etc.) for the 1st page I load (e.g. God.html) do not get effected in a 2nd and different page (e.g. Compassion.html) loaded in the same WV, I am right now loading the 2nd page in the manner below. Is that correct? If not, what is the correct method?
Code:
If WV.BindTo(picWV.hWnd) <> 0 Then
WV.Navigate App.Path & "\Cosmos\" & "Compassion.html"
End If
If I load the 2nd page straightaway using just the following line of code alone, then the scripts added to the 1st page get effected in the 2nd page also if I have elements in the 2nd page with the same 'id's (or classes) as in the 1st page.
Code:
WV.Navigate App.Path & "\Cosmos\" & "Compassion.html"
Note: I looked for any 'RemoveScript' methods so that by executing them I can remove the scripts already added to a WV so that I can use the abovementioned line of code alone directly. But, I could not find any. I am yet to get time to explore as to what RemoveObject method does.
God Bless you, olaf! God Bless ALL!
Kind regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
So, what is the right way to proceed if I need to add an EventListener to a specific target element alone?
Why not use the global Listener, when it works nicely already?
I'd make it even more generic, so that it works for any Widget which raises a change-event:
(this way you can filter on the VB-side)...
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True 'ensure Visibility before the Bind-call
Set WV = New_c.WebView2(Me.hWnd)
With New_c.StringBuilder
.AddNL "document.addEventListener('change', (e)=>{"
.AddNL " vbH().RaiseMessageEvent(e.target.id+'_change', e.target.value)"
.AddNL "})"
WV.AddScriptToExecuteOnDocumentCreated .ToString
End With
WV.NavigateToString "<input id='abc' type='text'><br><br><textarea id='xyz'>"
End Sub
Private Sub WV_JSMessage(ByVal sMsg As String, ByVal sMsgContent As String, oJSONContent As RC6.cCollection)
Select Case LCase$(sMsg)
Case "abc_change": Debug.Print "abc was changed to:"; sMsgContent
Case "xyz_change": Debug.Print "xyz was changed to:"; sMsgContent
End Select
End Sub
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Why not use the global Listener, when it works nicely already?
I'd make it even more generic, so that it works for any Widget which raises a change-event:
(this way you can filter on the VB-side)...
... .. . ... .. .
Olaf
// Why not use the global Listener, when it works nicely already? //
Yes, I definitely shall, olaf. I needed such a confirmation from you. Because, otherwise, I was somewhat concerned whether listening to events at the document level would increase the load on the 'events manager'. Now that you have given your assured go-ahead with a beautiful tip of a generic method itself, I am confident now that I need not have any concerns as aforesaid. Thanks a TON, as always.
Kind regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I think my question was misleading. I would like to ask how I could then interact with the hotspots that I assigned.
Does your framework perhaps offer a built-in method to iterate over them? I am not yet sure how I should access them, for example to get all the links in a webpage or to assign a different color to a hotspot area.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
// and were discussed more than once in this thread's history //
... .. .
Well, coming to the Bind-Call (e.g.
"--accept-lang=en-US,en,fr" wherein I have included 'fr' also to be considered for spellchecking), I wish to know the following:
1. For the spellchecker/word-suggestions to function (for any included language), does MS always send the words typed to its servers, to get the required results? Or, is it always done locally after downloading the required language dictionaries once (perhaps updated occasionally too) to user's system?
How "exactly" is this spell-checker/word-suggestions functionality effected by MS in WebView2? Will be helpful to share this info with users if such info is "concretely" known.
2. Is it possible to access the word suggestions programmatically and show it in my own separate list?. For instance, when I typed "SpellChecker", the spellchecker engine identifies it as misspelt and when I right click on it, the resultant context menu is as in the picture below.
Is it possible for me to programmatically access these three word suggestions (Spellchecker, Spellcheckers, Spell-checker) and show them alone in my own list on right-clicking (OR any other way, so that the default right-click menu gets displayed as usual)?
https://www.vbforums.com/image/png;b...AASUVORK5CYII=
Attachment 187181
3. I noticed that if I use more than one reference (say WV and WV2) to cWebView2 in my program, then while binding, I needed to "exactly" give the same "--accept-lang" argument in both Bindings. i.e. it had to be as follows:
--
If WV.BindTo(picWV.hWnd, TIME_TO_WAIT_m, , , "--accept-lang=en-US,en,fr") = 0
If WV2.BindTo(picWV2.hWnd, TIME_TO_WAIT_m, , , "--accept-lang=en-US,en,fr") = 0
--
Otherwise, the 2nd binding won't happen. I have no problems keeping the same argument in both bind calls, but I feel that perhaps I am doing a mistake and
there possibly is a way by which I can pass different "--accept-lang" argument in each of the WV bind calls. May be the correct argument is different from "--accept-lang" itself for SpellChecker?
... .. .
Kind Regards.
With respect to my above post, Since Olaf may not be finding time always, can somebody else (dear JpBro, dear Wwolf, ..., .., .), if at all their time and situation permits, kindly help me out providing answers to my above 3 questions.
There is also a sub-question in my 3rd question above. Let me pose it as a separate question hereunder so that it is easier for anyone to answer.
--
I have used "--accept-lang=en-US,en,fr" in the 'BindTo' call to enable and make use of the SpellChecker/WordSuggestions facility of Edge-WebView2 for languages other than the default English. Is that enough? Is that exactly the right way? If so, has anybody found time to use it extensively? And, if so, is the Spellchecking/WordSuggestions facility working well under all situations?
--
Sorry that I have not found time yet to explore the Spellchecking/WordSuggestions facility extensively, myself. Also, first I need to get confirmed from Olaf or others that "--accept-lang=en-US,en,fr" is enough and its the right way to enable and make use of the Spellchecking/WordSuggestions facility.
Thanks in advance.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
...kindly help me out providing answers to my above 3 questions.
...as for 1)
MS-WebView2 is still "just a relatively thin wrapper" around the chromium -opensource-project (mainly managed by google) - and therefore all the main-functionalities (as e.g. spellchecking and its context-menus) are in all likelihood "chromium-implementations".
There might be an exception here, regarding the necessary dictionaries (compared to chromium-CEF-binaries on e.g. Linux).
I'm not sure whether MS is redirecting to the "local OS-dictionaries, which come with the Win-language-packs" -
this might be the case, to keep the "Edge-Evergreen-package" relatively small... though I'm not sure about that...
"Constant online-access" (to do word-lookups) does not seem to happen in my tests...
(have temporarily disabled any Inet-connections here - and get proper spell-suggestions for "de" and "en" nevertheless.
...as for 2)
There's currently no "context-menu-parsing" exposed in the RC6.cWebView2-class -
(although interfaces for that exist in the MS-typelib).
There's also no way, to retrieve the contextmenu-contents at "js-level".
What is supported currently is, to entirely suppress any context-menu-popups (AreContextmenusEnabled) -
and then show your own, by using the appropriate ContextMenu-EventHandler (according to the transported x/y-pos).
...as for 3)
Was astonished by that myself (that the commandline-args have to remain constant for a Process-session) -
but have not tried to find a reason or a workaround, because I can live with the behaviour...
Perhaps changing the "UserDataFolder" in the Bind-call for the second instance could help, but haven't tested that either.
Generally, the browser-internal spellchecking functionality is not well-exposed
(only very few things can be influenced via javascript),
and that's the reason why there's such an amount of js-libs which address this
(usually in conjunction with some <textarea>bindings).
It's up to you to use some of these libs (or the "big-guns" like CKEditor or TinyMCE, which come with their own spellcheckers as well).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
I would like to ask how I could then interact with the hotspots that I assigned.
Does your framework perhaps offer a built-in method to iterate over them?
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
-
1 Attachment(s)
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
...as for 1)
MS-WebView2 is still "just a relatively thin wrapper" around the chromium -opensource-project (mainly managed by google) - and therefore all the main-functionalities (as e.g. spellchecking and its context-menus) are in all likelihood "chromium-implementations".
There might be an exception here, regarding the necessary dictionaries (compared to chromium-CEF-binaries on e.g. Linux).
I'm not sure whether MS is redirecting to the "local OS-dictionaries, which come with the Win-language-packs" -
this might be the case, to keep the "Edge-Evergreen-package" relatively small... though I'm not sure about that...
"Constant online-access" (to do word-lookups) does not seem to happen in my tests...
(have temporarily disabled any Inet-connections here - and get proper spell-suggestions for "de" and "en" nevertheless.
...as for 2)
There's currently no "context-menu-parsing" exposed in the RC6.cWebView2-class -
(although interfaces for that exist in the MS-typelib).
There's also no way, to retrieve the contextmenu-contents at "js-level".
What is supported currently is, to entirely suppress any context-menu-popups (AreContextmenusEnabled) -
and then show your own, by using the appropriate ContextMenu-EventHandler (according to the transported x/y-pos).
...as for 3)
Was astonished by that myself (that the commandline-args have to remain constant for a Process-session) -
but have not tried to find a reason or a workaround, because I can live with the behaviour...
Perhaps changing the "UserDataFolder" in the Bind-call for the second instance could help, but haven't tested that either.
Generally, the browser-internal spellchecking functionality is not well-exposed
(only very few things can be influenced via javascript),
and that's the reason why there's such an amount of js-libs which address this
(usually in conjunction with some <textarea>bindings).
It's up to you to use some of these libs (or the "big-guns" like CKEditor or TinyMCE, which come with their own spellcheckers as well).
Olaf
Thanks a TON, as always, dear Olaf.
And, before anything else, I just presume from your detailed answers that "--accept-lang" is indeed the right way, as of now, to add SPWS (short for SpellChecker/WordSuggestions) facility via WebView2 in our own applications and that is enough too (though SPWS via "--accept-lang" does not seem to work for some languages; please see details in my "observations" below). So, I can very much go ahead using "--accept-lang" in my applications to enable and make use of SPWS (for whatever languages it works for now). Right? Kindly confirm.
Well, I took time to explore more on this SPWS (short for SpellChecker/WordSuggestions) facility since the past 5 hours or so. And, noted down the following observations. As I was doing that, when I checked in between, I saw your answers to my 3 questions, that too in such great detail. Thanks a TONNNN, again, dear Olaf. Well, a few(not all) portions of my following observations may have been already responded to by you in your recent answers but if I start rephrasing my following observations, it may turn out to be a difficult/confusing process for me since already I have spent quite some time phrasing and rephrasing them in an understandable manner. So, I am sharing my observations just as I originally started noting them down itself and not modifying them based on your recent answers. Kindly bear with me for the same. Thanks in advance for your understanding in this regard.
My observations:
--
1. When using "--accept-lang" to enable and use SPWS, some languages work and others don't. For instance, "fr,de,es,ta,hi,ml,te" work but NOT "ar,sa,kn,mr,gu,pa,as,bn". To confirm that all the language codes I am specifying are correct only, I referred to this page - https://www.biswajeetsamal.com/blog/...fication-codes. It came first on google search for "browser language codes" and I just used it. That's all.
2. As an example for the abovementioned observation, if "--accept-lang=ar-AE,es,kn,en-US,en,fr-FR,de,as,bn" is specified in the BindTo call, the "Check spelling" context menu shows "Spanish, English (United States), English, French (France), German)" alone. i.e. only "es, en-US, en, fr-FR, de" are considered for spell-checking. "ar,kn,as,bn" are not considered. Please see screenshot at the end of this message (I opted to place the screenshot at the end so that the flow of this long message is not disturbed while reading).
3. I just tried providing a list of non-working languages alone to "-accept-lang". That did not work. I tried placing the non-working languages in a different order in the list, just in case. That did not help either.
4. For some sets of languages specified, I noticed that if a language which does NOT work is found in the list, even a language for which SPWS works is not shown in the "Check spelling" context menu.
For example, if "--accept-lang=en,fr,ta,hi,te,ml,mr" is specified in the BindTo call, the "Check spelling" context menu shows "English, French, Tamil, Hindi" (en,fr,ta,hi) alone. "te,ml" are not shown. This is because of the 'mr'(Marathi) after 'ml'(Malayalam). In other words, if 'mr' is omitted and if "--accept-lang=en,fr,ta,hi,te,ml" is specified in the BindTo call, the "Check spelling" context menu does show all of "English, French, Tamil, Hindi, Telugu, Malayalam".
5. In my Microsoft Edge browser (updated to the latest - 111.0.1661.51), under 'Settings->Languages->User writing assistance', it shows two modes of SPWS - 'Microsoft Editor' mode and 'Basic' mode. It is mentioned therein that if the former is used, "enhanced" SPWS is done by MS and the typed words are sent to MS for processing. If the latter is used, typed words are processed locally. What mode possibly WebView2 could be using?
6. Since the SPWS seem to work when the internet is OFF also, only the 'Basic' mode is used by WebView2? If so and if 'Microsoft Editor' mode has to be used for "enhanced" SPWS, what should be done (if at all it can be done with the current WebView2 itself)? I just checked the SPWS with a limited set of words only for a few languages both with internet ON and OFF. Need to check with 5 to 6 sets of BIG chunk of words for the same few languages at some later point of time, to see whether the same misspelt words are shown underlined both when internet is ON and OFF.
7. For some languages, MS Edge itself says that SPWS is not yet supported. For e.g. for "Bangla(India)".
8. I noticed that sa(Sanskrit) was not found in the original list (of languages provided by MS Edge to add for SPWS) itself.
9. https://github.com/nwjs/nw.js/issues/4954 - in this page, this comment (https://github.com/nwjs/nw.js/issues...ment-607348899) suggests a summary of 3 very simple things to do to add SPWS facility via package.json and Javascript. This thread was in 2017 though. So, I don't know whether the same is applicable via JavaScript to WebView2 too. If it is applicable and if it can serve as an additional way (apart from "--accept-lang") to enable and use SPWS for different languages, then, when your time permits, kindly elucidate more on the same, because I am not familiar with package.json, etc. May be SPWS for the currently non-working languages (ar,kn,gu,pa,etc.) will work through the aforementioned JS way?
10. Even if I remove all the languages added through my MS Edge, I was still able to add SPWS facility via WebView2 in my application. So, MS language settings do not seem to have any connection with the language settings added via BindTo call in my application. Only thing is that WebView2 does not seem to support SPWS for all languages, for whatever reasons. Or perhaps I am doing some mistake. If I am doing some mistake, then, kindly point out the same so that I am able to enable and use SPWS facility for the currently non-working languages (ar, kn, gu, pa, etc.) too via "--accept-lang".
11. Thanks for your helpful suggestion on js-libs for SPWS. Actually, I also noticed (just today, during my above exploration) that some js libs are available for spellchecking. I did not explore what they are though. If they are of MIT License supporting many languages, that would be great. Otherwise, for the kind of freeware-only work I do, whatever languages currently supported by WebView2 are itself such an "extremely exciting" thing. Really. Thanks for your suggestions, once again.
--
All said and done, as requested at the start of this message, kindly confirm, dear Olaf, that I can very well go ahead using "--accept-lang" in my applications to enable and make use of SPWS (for whatever languages it works for now).
Once again, TONs of Thanks from the bottom of my heart for such prompt and detailed replies to each and every doubt of each and every user of RC6 in various threads related to RC6. And, those invaluable tips and cute compact code snippets now and then, to help us along with. God Bless you, dear Olaf. God Bless All.
Kindest Regards.
Screenshot (for point no.2 above):
Attachment 187220
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I make a software for handicapped people.
I need to get the links and clickable button elements of a webpage in order to show them on extra big buttons in my software.
Instead of clicking in the website, handicapped users can press the big buttons in my software.
At a first click on a button, the element in the webpage will be highlighted with a red outline, and its text will be spoken by a computer voice.
At a 2nd click on the button in my application, the link of them element will be navigated to.
That is why I need to be able to iterate through these elements from outside.
For example, when the user presses button #2, I need to highlight hotspot #2 in the webpage.
Can you tell me what you mean by "complex DOM-operations remain "in generic, clever parametrized js-helpers"?
If possible, could you show me how to iterate over these hotspots from within VB6 using JS?
I don't know how I could get back an array of hotspots from the browser by calling the JS function. I hope I could explain it well.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Note: This is a follow-up message to my post No. 297 ("11-point observations" message).
First thing first, Olaf. SPWS works for all the languages with "--accept-lang" argument. :)
What happened was that after a while after sending my "11-point observations" message to you, it occurred in my mind that I was all the while concentrating on adding languages to MS Edge rather than checking the Language packs installed in my system. At that point of time, your wise statement (I'm not sure whether MS is redirecting to the "local OS-dictionaries, which come with the Win-language-packs") also came to my mind simultaneously.
So, I checked the language packs installed and found out that language packs for only a few languages (out of the many languages I was checking out) were installed in my Win10 system. So, I started installing the missing language packs but for whatever reasons, none of the language packs got installed, however many times I tried. That is when it occurred to me that I can easily check out the compiled exe in one of my other Win10 systems which I use only now and then (but keep its OS upto-date with the latest OS updates whenever I use it).
So, I switched on my other system and checked out the compiled exe. And, all languages worked straightaway! :). I checked the language packs installed in my other system and all the required language packs had been installed in it. So, as of now, SPWS works for all the languages with "--accept-lang" argument. The thing is that, as guessed by you very correctly (as it is so usually :)), the language packs for all the languages for which SPWS is needed should be installed priorly in the system. Thanks a TON ton ton, my dear Olaf.
Well, in the complied exe I had "--accept-lang=ta,hi,sa,te,kn,ml,mr,kok,gu,bn,pa,or,as,ar,es,en-US,en,fr-FR,de" and all of them (19 languages) showed up in the "Check spelling" context menu.
One more thing. In my eagerness to check out the working of SPWS in my other system, I forgot the fact that I was checking out the compiled exe in one other system (in which RC6 is not installed/registered) for the very first time. So, when the starting screen of the compiled exe appeared, only after a second I realised that the compiled exe started "registration-free". Hats off to you, Olaf. This is the first time I am running a "compiled exe with DLL dependencies" and yet seeing it opening without me having to register the DLLs myself. Your DirectCOM.dll does it automatically. I did use your "modRCRegFree.bas" drop-in in my application, just exactly as you had suggested. :). Thanks once again.
All said and done, as requested in my earlier post (11-point message), when possible, kindly give your confirmation that I can very well go ahead using the "--accept-lang" approach in my applications to enable and make use of SPWS and no issues are foreseen in this approach/method. Thanks in advance. Any helpful/useful/important tips that you wish to give me when I go forward using this "--accept-lang" approach for SPWS, kindly let me know please. Looking forward to the same too. God Bless you, olaf. God Bless ALL.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
By the way, Olaf, thanks (as usual) A TONNNN for your most wonderful tip on VSCODE editor (in post no. 277).
What a gem this little cute editor is! I was thinking that VSCODE would be yet another bulky IDE (like Visual Studio) where I would be taking several days to learn (and also remember) the IDE's various menus/options/features itself. But it was not at all so! It was such a pleasant surprise and joy to see VSCODE being so light-weight (yet features-packed!). I never knew that such a tailor-made cute little app can exist for html5/css/js coding. It has all the features (and more :)) one would expect in an html/css/js editor. Simply Fantastic. Happy that I got to see this helpful tip of yours early. Your superb tip has saved me so many hours thereafter and increased my productivity a lot. You are so special for our VBForums. Thanks once again. :).
Kindest Regards.