Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]
Re: Webview2 control - Chromium browser for Purebasic (Windo
so bad, the installer for Evergreen Standalone Installer on windows 64bits is 92.7MB.
It reminds me of .NET framework of many years ago, which also needs to be installed by end-users manually, furthermore with not little disk occupation; as a result .NET does not populate quickly as expected.
There are ways to make application written in .NET portable, I mean copy and run even on PC without installing .NET framework. Is it possible for webview2?
It reminds me of .NET framework of many years ago, which also needs to be installed by end-users manually, furthermore with not little disk occupation; as a result .NET does not populate quickly as expected.
There are ways to make application written in .NET portable, I mean copy and run even on PC without installing .NET framework. Is it possible for webview2?
Re: Webview2 control - Chromium browser for Purebasic (Windo
Thanks for the update!Justin wrote:Hi, thanks for the feedback.
I updated to the latest WebView2 SDK 1.0.705.50 / 1.0.781-prerelease, see first post. There are some interesting new apis in the prerelease.
oyster,
Basically you need the WebView2 Runtime installed in the machine and the WebView2Loader.dll from the WebView2 SDK in the executable folder.
The distribution model is explained here:
https://docs.microsoft.com/en-us/micros ... stribution
WebView2 Runtime download:
https://developer.microsoft.com/en-us/m ... /webview2/
2 quick questions, if you don't mind:
Is there a way to remove devtools (Inspect) from the context menu
Is there a way to intercept and stop a connection before it loads (similar to the Webgadget NavigationCallback)?
Re: Webview2 control - Chromium browser for Purebasic (Windo
Hi fluent,
The devs tools entry is disabled through the settings object, put_AreDevToolsEnabled() method. In the bootstrap.pb example, in wvController_Created() procedure simply coment the line:
sett\put_AreDefaultContextMenusEnabled(#False)
This will enable the context menu, but since sett\put_AreDevToolsEnabled(#False) is later called the dev tools entry will not show.
Cancel navigation is done handling the NavigationStarting event, i have updated the basic_browser_async.pb example with that.
Basically after registering for the event you do something like this:
See basic_browser_async.pb
oyster,
The only way to distribute in portable format without installing anything is through the 'Fixed Version distribution mode' as explained in the link, you download the fixed version package, put your executable in it an use CreateCoreWebView2EnvironmentWithOptions to set the browserExecutableFolder. But it takes 134MB compressed, 295MB uncrompessed
I think it's not a big deal to create an installer that installs the runtime only if it's not installed or prompt the user to install the runtime, although i would prefer that it came preinstalled with windows.
There have been requests for a stripped down version and for an in memory user data folder but i don't see it happening.
The devs tools entry is disabled through the settings object, put_AreDevToolsEnabled() method. In the bootstrap.pb example, in wvController_Created() procedure simply coment the line:
sett\put_AreDefaultContextMenusEnabled(#False)
This will enable the context menu, but since sett\put_AreDevToolsEnabled(#False) is later called the dev tools entry will not show.
Cancel navigation is done handling the NavigationStarting event, i have updated the basic_browser_async.pb example with that.
Basically after registering for the event you do something like this:
Code: Select all
Procedure wv_NavigationStarting(*this.WV2_EVENT_HANDLER, sender.ICoreWebView2, args.ICoreWebView2NavigationStartingEventArgs)
Protected.i uri
Protected.s suri
Debug "Event NavigationStarting"
If args\get_uri(@uri) = #S_OK
suri = PeekS(uri)
CoTaskMemFree_(uri)
;CANCEL NAVIGATION
If LCase(StringField(GetURLPart(suri, #PB_URL_Site), 2, ".")) = "google"
MessageRequester("Purebasic", "Sorry google is banned.")
args\put_Cancel(#True)
EndIf
EndIf
EndProcedure
oyster,
The only way to distribute in portable format without installing anything is through the 'Fixed Version distribution mode' as explained in the link, you download the fixed version package, put your executable in it an use CreateCoreWebView2EnvironmentWithOptions to set the browserExecutableFolder. But it takes 134MB compressed, 295MB uncrompessed
I think it's not a big deal to create an installer that installs the runtime only if it's not installed or prompt the user to install the runtime, although i would prefer that it came preinstalled with windows.
There have been requests for a stripped down version and for an in memory user data folder but i don't see it happening.
Re: Webview2 control - Chromium browser for Purebasic (Windo
Thanks a lot Justin - I've just tried the new basic_browser_async.pb and it's working great, but would you know if it can also cancel connections to page subresources (for instance, allowing navigation to http://www.purebasic.com but cancelling the loading of the PureBasic logo at https://www.purebasic.com/img/pb-logo-white.png), or is there another event for that?
(This is mainly out of curiosity BTW - I certainly don't want to waste your time if there is no "easy" solution for that)
EDIT: Ah, nevermind, found your resources.pb example. Fantastic!
(This is mainly out of curiosity BTW - I certainly don't want to waste your time if there is no "easy" solution for that)
EDIT: Ah, nevermind, found your resources.pb example. Fantastic!
Re: Webview2 control - Chromium browser for Purebasic (Windo
Very good work
is there a manual of the available function?
can you retrieve html (content) of page that has been loaded ?
is there a manual of the available function?
can you retrieve html (content) of page that has been loaded ?
Christos
Re: Webview2 control - Chromium browser for Purebasic (Windo
Hi plouf,
Currently the only way to get the HTML content it's trhough executing javascript, a direct interface method has been requested in the webview forum.
To get all the content use:
To get only the body:
To test it go to the bootstrap.pb example, and in the menu_GetPassword_Click() procedure replace the script with one of those and you will get the result.
Note that wv2_Core_ExecuteScriptSync() is a helper function that can only be called in a non binded event procedure, otherwise you will have to use the native ExecuteScript method and get the result in the script executed event handler, i'll update the examples later.
As for the manual i guess is the win32 reference or the getting started part:
https://docs.microsoft.com/en-us/micros ... 1.0.705.50
https://docs.microsoft.com/en-us/micros ... rted/win32
Once you get an object you can use all its methods, all the interfaces are ported to pb. The examples are a good start i covered the most important things.
Currently the only way to get the HTML content it's trhough executing javascript, a direct interface method has been requested in the webview forum.
To get all the content use:
Code: Select all
script = "new XMLSerializer().serializeToString(document);"
Code: Select all
script = "document.body.outerHTML;"
Note that wv2_Core_ExecuteScriptSync() is a helper function that can only be called in a non binded event procedure, otherwise you will have to use the native ExecuteScript method and get the result in the script executed event handler, i'll update the examples later.
As for the manual i guess is the win32 reference or the getting started part:
https://docs.microsoft.com/en-us/micros ... 1.0.705.50
https://docs.microsoft.com/en-us/micros ... rted/win32
Once you get an object you can use all its methods, all the interfaces are ported to pb. The examples are a good start i covered the most important things.
Re: Webview2 control - Chromium browser for Purebasic (Windo
Thanx
But i cant think i can inject javascript to an existing page
What i am trying to o is to get a page html in order to extract some data
But i cant think i can inject javascript to an existing page
What i am trying to o is to get a page html in order to extract some data
Christos
- the.weavster
- Addict
- Posts: 1537
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Re: Webview2 control - Chromium browser for Purebasic (Windo
Microsoft has started auto-installing WebView2 on Windows 10 PCs
*Edit
... if they have Office 365 installed
Re: Webview2 control - Chromium browser for Purebasic (Windo
Check out the Html Agility Pack.plouf wrote:What i am trying to o is to get a page html in order to extract some data
Re: Webview2 control - Chromium browser for Purebasic (Windo
Hi, my Windows just got upgraded to version 20H2, which ships the Webview2 control by default (yay!), so I removed my installation of Edge Beta, but now my apps can no longer find the Webview2 control unfortunately:
I just manually verified that it is present in this path: C:\Program Files (x86)\Microsoft\Edge
Any ideas? Thanks!
Code: Select all
---------------------------
Error
---------------------------
System webview2 not found - Install MS Edge Runtime.
---------------------------
OK
---------------------------
Any ideas? Thanks!
Re: Webview2 control - Chromium browser for Purebasic (Windo
Hi,
is that error the result of this code?
if so i think you can just comment it and it should work.
I'll take a closer look later.
is that error the result of this code?
Code: Select all
If wv2_GetBrowserVersion("") = ""
MessageRequester("Error", "MS Edge not found, install MS Edge Runtime.")
End
EndIf
I'll take a closer look later.
Re: Webview2 control - Chromium browser for Purebasic (Windo
As said in a post above the runtime is only installed with Microsoft 365 and Microsoft Office for now.
To check if the runtime is installed the regkey 'pv' in:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
must exist with a value.
Explained here:
https://docs.microsoft.com/en-us/micros ... stribution
I'll update the code with some functions, wv2_GetBrowserVersion() only checks if Edge browser is installed so it's not reliable.
It's a bit of a mess because applications can run without the runtime installed but with dev channel installed, although dev it's only for developers to test new functions, the end user must have always the stable runtime installed.
To check if the runtime is installed the regkey 'pv' in:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
must exist with a value.
Explained here:
https://docs.microsoft.com/en-us/micros ... stribution
I'll update the code with some functions, wv2_GetBrowserVersion() only checks if Edge browser is installed so it's not reliable.
It's a bit of a mess because applications can run without the runtime installed but with dev channel installed, although dev it's only for developers to test new functions, the end user must have always the stable runtime installed.
Re: Webview2 control - Chromium browser for Purebasic (Windo
Ah, understood. Thank you for the clear reply!
Re: Webview2 control - Chromium browser for Purebasic (Windo
Hi, i was a bit dense wv2_GetBrowserVersion() is perfectly reliable to get the runtime version, but i also added wv2_GetRuntimeVersionFromRegistry() to get it from the registry.
Updated to the last Webview2 SDK 1.0.774.44 / 1.0.824-prerelease
Updated to the last Webview2 SDK 1.0.774.44 / 1.0.824-prerelease
Re: Webview2 control - Chromium browser for Purebasic (Windo
I didn't had a case to use browser in some PB apps (few times I only used "headless" browsers), but just curious looking at this thread, is this control alternative to CEF, or they are different? Thanks if someone can describe a bit.
https://bitbucket.org/chromiumembedded/cef
https://bitbucket.org/chromiumembedded/cef
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"