Repository navigation
Conversation #9
Description
Activity
For now, I have working:
- Stop navigation command [DONE]
- Allow Notifications [DONE]
- Block popup windows [DONE]
- Fix minor bug on AllowDualControl [DONE]
- Experimental Measure's String and Number value returns rework [DONE]
- Experimental Navigation to URL system rework [DONE]
- WebView lifecycle system [DONE]
- Add RainmeterAPI support for iframes [DONE]
- Non-JS alternative to AllowDualControl [DONE]
- Implement user settings [DONE]
--End of PR--
I'm working on:
- Scripting [PLANNING]
Reacted by NSTechBytes and YincognytoReacted by YincognytoSo as commented above, here's a testing build:
Will be deleted at some point
[Deleted]New options:
AllowNewWindow[Default 0]
By default it will block any website from opening links in a new window, unfortunately, it also avoids the user from manually opening things on new windows by right click - Open in new window, there's no way around this I could find. Set to 1 if you want windows.AllowNotifications[Default 0]
WebView doesn't allow to use the Notifications API by default, now we can use it by setting this option to1.
New commands:
Stop
This new command will stop any navigation. To test, open DevTools - Network tab - change No throttling to 3G to purposely slow down your connection. Then use the command while the site is loading to stop it.
Fixes
AllowDualControlscript should now work fine whenZoomFactoris not1.0- No website should be able to trigger popup windows by using scripts anymore, they are blocked independently from
AllowNewWindowvalue.
Testing skins:
BangCommand.ini
[Rainmeter] Update=1000 AccurateText=1 DynamicWindowSize=1 [Metadata] Name=BangCommand Author=nstechbytes Information=Demonstrates controlling WebView2 via !CommandMeasure bangs. Version=0.0.7 License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0 [Variables] W=920 H=630 WebURL=https://www.bing.com/ WebW=600 WebH=560 WebX=300 WebY=45 ZoomFactor=1.0 Hidden=0 ClickThrough=0 AllowDualControl=1 AllowNewWindow=0 ; ======================================== ; Measure ; ======================================== [MeasureWebView] Measure=Plugin Plugin=WebView2 URL=#WebURL# W=#WebW# H=#WebH# X=#WebX# Y=#WebY# ZoomFactor=#ZoomFactor# Hidden=#Hidden# ClickThrough=#ClickThrough# AllowDualControl=#AllowDualControl# AllowNewWindow=#AllowNewWindow# OnWebViewLoadAction=[!log "WebView loaded succesfully!"] OnWebViewFailAction=[!log "WebView failed :("] OnPageFirstLoadAction=[!log "First time on this page!"] OnPageLoadStartAction=[!log "Navigation has started!"] OnPageLoadingAction=[!log "Page is loading!"] OnPageLoadFinishAction=[!log "Navigation has finished!"] OnPageReloadAction=[!log "Page has been reloaded!"] DynamicVariables=1 ; ======================================== ; Background ; ======================================== [MeterBackground] Meter=Shape Shape=Rectangle 0,0,#W#,#H#,12 | FillColor 0,0,0,200 | StrokeWidth 0 [Title] Meter=String Text=Bang Command Demo FontSize=16 FontColor=255,255,255,255 AntiAlias=1 X=25 Y=10 [StyleButtonText] FontColor=255,255,255,255 FontSize=12 AntiAlias=1 W=250 H=25 X=150 Y=3R StringAlign=CenterCenter SolidColor=0,200,255,150 ; ======================================== ; Navigate to URL (Dynamic Variables) ; ======================================== [TxtNavigateGoogle] Meter=String MeterStyle=StyleButtonText Text=Navigate to Google (via Variable) Y=58 LeftMouseUpAction=[!SetVariable WebURL "https://www.google.com"][!UpdateMeasure MeasureWebView] [TxtNavigateGitHub] Meter=String MeterStyle=StyleButtonText Text=Navigate to GitHub (via Variable) LeftMouseUpAction=[!SetVariable WebURL "https://github.com"][!UpdateMeasure MeasureWebView] [TxtNavigateForum] Meter=String MeterStyle=StyleButtonText Text=Navigate to Forum (via Bang) LeftMouseUpAction=[!CommandMeasure MeasureWebView "Navigate https://forum.rainmeter.net/"] [TxtReload] Meter=String MeterStyle=StyleButtonText Text=Reload LeftMouseUpAction=[!CommandMeasure MeasureWebView "Reload"] [TxtStop] Meter=String MeterStyle=StyleButtonText Text=Stop LeftMouseUpAction=[!CommandMeasure MeasureWebView "ResetPermissions"] [TxtGoBack] Meter=String MeterStyle=StyleButtonText Text=Go Back W=122 H=24 X=86 LeftMouseUpAction=[!CommandMeasure MeasureWebView "GoBack"] [TxtGoForward] Meter=String MeterStyle=StyleButtonText Text=Go Forward W=125 H=24 X=4R Y=r LeftMouseUpAction=[!CommandMeasure MeasureWebView "GoForward"] [TxtShow] Meter=String MeterStyle=StyleButtonText Text=Show W=122 H=24 X=86 LeftMouseUpAction=[!SetVariable Hidden 0][!UpdateMeasure MeasureWebView] [TxtHide] Meter=String MeterStyle=StyleButtonText Text=Hide W=125 H=24 X=4R Y=r LeftMouseUpAction=[!SetVariable Hidden 1][!UpdateMeasure MeasureWebView] [TxtExecuteScript] Meter=String MeterStyle=StyleButtonText Text=Execute Script LeftMouseUpAction=[!CommandMeasure MeasureWebView "ExecuteScript console.log('Script has been executed.')"] [TxtOpenDevTools] Meter=String MeterStyle=StyleButtonText Text=Open DevTools LeftMouseUpAction=[!CommandMeasure MeasureWebView "OpenDevTools"] [TxtSetWidth] Meter=String MeterStyle=StyleButtonText Text=Set Width: 500 (via Variable) LeftMouseUpAction=[!SetVariable WebW (#WebW#=600?500:600)][!UpdateMeasure MeasureWebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetHeight] Meter=String MeterStyle=StyleButtonText Text=Set Height: 400 (via Variable) LeftMouseUpAction=[!SetVariable WebH (#WebH#=410?470:410)][!UpdateMeasure MeasureWebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetX] Meter=String MeterStyle=StyleButtonText Text=Set X: 320 (via Variable) LeftMouseUpAction=[!SetVariable WebX (#WebX#=300?320:300)][!UpdateMeasure MeasureWebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetY] Meter=String MeterStyle=StyleButtonText Text=Set Y: 50 (via Variable) LeftMouseUpAction=[!SetVariable WebY (#WebY#=45?50:45)][!UpdateMeasure MeasureWebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetZoom] Meter=String MeterStyle=StyleButtonText Text=Set ZoomFactor: 0.5 (via Variable) LeftMouseUpAction=[!SetVariable ZoomFactor (#ZoomFactor#=1?0.5:1)][!UpdateMeasure MeasureWebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetEnableClickThrough] Meter=String MeterStyle=StyleButtonText Text=Set ClickThrough: 1 (via Variable) LeftMouseUpAction=[!SetVariable ClickThrough 1][!UpdateMeasure MeasureWebView] [TxtSetDisableClickThrough] Meter=String MeterStyle=StyleButtonText Text=Set ClickThrough: 0 (via Variable) LeftMouseUpAction=[!SetVariable ClickThrough 0][!UpdateMeasure MeasureWebView] [TxtSetEnableAllowDualControl] Meter=String MeterStyle=StyleButtonText Text=Set AllowDualControl: 1 (Variable) LeftMouseUpAction=[!SetVariable AllowDualControl 1][!UpdateMeasure MeasureWebView] [TxtSetDisableAllowDualControl] Meter=String MeterStyle=StyleButtonText Text=Set AllowDualControl: 0 (Variable) LeftMouseUpAction=[!SetVariable AllowDualControl 0][!UpdateMeasure MeasureWebView] [TxtSetEnableOpenNewWindow] Meter=String MeterStyle=StyleButtonText Text=Set AllowNewWindow: 1 (Variable) LeftMouseUpAction=[!SetVariable AllowNewWindow 1][!UpdateMeasure MeasureWebView] [TxtSetDisableOpenNewWindow] Meter=String MeterStyle=StyleButtonText Text=Set AllowNewWindow: 0 (Variable) LeftMouseUpAction=[!SetVariable AllowNewWindow 0][!UpdateMeasure MeasureWebView]Permissions.ini
Extract the zip inside the WebView skin folder. Refresh Rainmeter and load Permissions.ini to test all available permissions. To allow notifications set
AllowNotifications=1You can also use this website to test the Notifications API: https://web-push-book.gauntface.com/demos/notification-examples/
Reacted by NSTechBytesAlright, in addition to the above, I have finished the two experimental reworks I wanted to propose.
Measure's String and Number value returns rework
Instead of allowing the user to return custom delayed values through window.OnInitialize and OnUpdate JavaScript functions, I propose a new system that returns the following:Number Value
The Measure's number value would express the current state of the plugin with the following values:- WebView waiting:
-1
This is the initial value. - WebView Initializing:
0
It starts its configuration - WebView Initialized:
1
It is fully initialized and ready - Navigation Start:
100
Navigation has started - Loading Site:
200
The site has started loading - Navigation Complete:
300
The site has finished loading, navigation is complete.
String Value
The string value would simply be the current URL.Current URL
However, this system is not complete without new actions:
Actions
OnStateChangeAction
This action would trigger every time the state changesOnUrlChangeAction
This action would trigger every time the URL changes
These actions will allow us to set variables, update meters, and so on to keep the skin updated to the latest measure values.
--
Navigation to URL system rework
There's currently an issue with the current way we navigate by setting theURLoption. We can only navigate if the URL changes, otherwise the button is simply blocked, this leads to confusion while trying to navigate. We can't fix it because otherwise we create a navigation loop on each update when DynamicVariables are enabled. So I propose to change the system:Now the Measure's URL option will be a home page URL. This is the URL where the plugin will navigate on first load, then we only navigate using the Navigate command. However, we need a new command as well:
Commands
GoHome
We navigate to the set URL on the measure by using[!CommandMeasure Measure "GoHome"]
The URL option remains the same, only that by changing it we simply change the home page URL, we then navigate to it using the
GoHomecommand.I believe this system is more consistent by only using commands to navigate, and variables to set options.
With all that being said, here's the testing build, it of course includes all changes on the comment above.
[Deleted]
And a modified version of
BangCommand.iniBangCommand.ini
[Rainmeter] Update=-1 AccurateText=1 DynamicWindowSize=1 [Metadata] Name=BangCommand Author=nstechbytes Information=Demonstrates controlling WebView2 via !CommandMeasure bangs. Version=0.0.7 License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0 [Variables] W=920 H=630 HomeURL=https://www.google.com WebW=600 WebH=560 WebX=300 WebY=45 ZoomFactor=1.0 Hidden=0 ClickThrough=0 AllowDualControl=1 AllowNewWindow=0 ; ======================================== ; Measure ; ======================================== [WebView] Measure=Plugin Plugin=WebView2 URL=#HomeURL# W=#WebW# H=#WebH# X=#WebX# Y=#WebY# ZoomFactor=#ZoomFactor# Hidden=#Hidden# ClickThrough=#ClickThrough# AllowDualControl=#AllowDualControl# AllowNewWindow=#AllowNewWindow# OnWebViewLoadAction=[!log "WebView loaded succesfully!"] OnWebViewFailAction=[!log "WebView failed :("] OnStateChangeAction=[!UpdateMeasure #CURRENTSECTION#] OnUrlChangeAction=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter CurrentURL][!Redraw] OnPageFirstLoadAction=[!log "First time on this page!"] OnPageLoadStartAction=[!log "Navigation has started!"] OnPageLoadingAction=[!log "Page is loading!"] OnPageLoadFinishAction=[!log "Navigation has finished!"] OnPageReloadAction=[!log "Page has been reloaded!"] ; These conditions change the State meter text and update it. IfCondition=WebView = -1 IfTrueAction=[!SetOption State Text "Waiting... (-1)"][!UpdateMeter State][!Redraw] IfCondition2=WebView = 0 IfTrueAction2=[!SetOption State Text "Initializing... (0)"][!UpdateMeter State][!Redraw] IfCondition3=WebView = 1 IfTrueAction3=[!SetOption State Text "Initialized (1)"][!UpdateMeter State][!Redraw] IfCondition4=WebView = 100 IfTrueAction4=[!SetOption State Text "Navigation Started (100)"][!UpdateMeter State][!Redraw] IfCondition5=WebView = 200 IfTrueAction5=[!SetOption State Text "Loading Site... (200)"][!UpdateMeter State][!Redraw] IfCondition6=WebView = 300 IfTrueAction6=[!SetOption State Text "Navigation Complete (300)"][!UpdateMeter State][!Redraw] DynamicVariables=1 [UrlInput] Measure=Plugin Plugin=InputText SolidColor=25,25,25 FontColor=255,255,255,255 FontSize=8 X=[&CurrentUrl:X] Y=[&CurrentUrl:Y] W=[&CurrentUrl:W] H=[&CurrentUrl:H] DefaultValue=[&WebView] Command1=[!CommandMeasure WebView "Navigate $UserInput$"] DynamicVariables=1 ; ======================================== ; Background ; ======================================== [Background] Meter=Shape Shape=Rectangle 0,0,#W#,#H#,12 | FillColor 0,0,0,200 | StrokeWidth 0 [Title] Meter=String Text=Bang Command Demo FontSize=16 FontColor=255,255,255,255 AntiAlias=1 X=25 Y=10 [State] Meter=String FontSize=8 FontColor=255,255,255,255 AntiAlias=1 StringAlign=LeftCenter ClipString=1 X=#WebX# Y=13 W=#WebW# DynamicVariables=1 [CurrentUrl] Meter=String MeasureName=WebView FontSize=8 FontColor=255,255,255,255 AntiAlias=1 StringAlign=LeftCenter ClipString=1 SolidColor=25,25,25 Padding=5,0,0,0 X=#WebX# Y=35 W=(#WebW#-5) H=20 LeftMouseUpAction=[!CommandMeasure "UrlInput" "ExecuteBatch 1"] [StyleButtonText] FontColor=255,255,255,255 FontSize=12 AntiAlias=1 W=250 H=25 X=150 Y=3R StringAlign=CenterCenter SolidColor=0,200,255,150 ; ======================================== ; Navigate to URL (Dynamic Variables) ; ======================================== [TxtGoHome] Meter=String MeterStyle=StyleButtonText Text=Go Home Y=58 LeftMouseUpAction=[!CommandMeasure WebView "GoHome"] [TxtNavigateGitHub] Meter=String MeterStyle=StyleButtonText Text=Navigate to GitHub LeftMouseUpAction=[!CommandMeasure WebView "Navigate https://github.com"] [TxtNavigateForum] Meter=String MeterStyle=StyleButtonText Text=Navigate to Forum LeftMouseUpAction=[!CommandMeasure WebView "Navigate https://forum.rainmeter.net/"] [TxtReload] Meter=String MeterStyle=StyleButtonText Text=Reload LeftMouseUpAction=[!CommandMeasure WebView "Reload"] [TxtStop] Meter=String MeterStyle=StyleButtonText Text=Stop LeftMouseUpAction=[!CommandMeasure WebView "Stop"] [TxtGoBack] Meter=String MeterStyle=StyleButtonText Text=Go Back W=122 H=24 X=86 LeftMouseUpAction=[!CommandMeasure WebView "GoBack"] [TxtGoForward] Meter=String MeterStyle=StyleButtonText Text=Go Forward W=125 H=24 X=4R Y=r LeftMouseUpAction=[!CommandMeasure WebView "GoForward"] [TxtShow] Meter=String MeterStyle=StyleButtonText Text=Show W=122 H=24 X=86 LeftMouseUpAction=[!SetVariable Hidden 0][!UpdateMeasure WebView] [TxtHide] Meter=String MeterStyle=StyleButtonText Text=Hide W=125 H=24 X=4R Y=r LeftMouseUpAction=[!SetVariable Hidden 1][!UpdateMeasure WebView] [TxtExecuteScript] Meter=String MeterStyle=StyleButtonText Text=Execute Script LeftMouseUpAction=[!CommandMeasure WebView "ExecuteScript console.log('Script has been executed.')"] [TxtOpenDevTools] Meter=String MeterStyle=StyleButtonText Text=Open DevTools LeftMouseUpAction=[!CommandMeasure WebView "OpenDevTools"] [TxtSetWidth] Meter=String MeterStyle=StyleButtonText Text=Set Width: 500 (Variable) LeftMouseUpAction=[!SetVariable WebW (#WebW#=600?500:600)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetHeight] Meter=String MeterStyle=StyleButtonText Text=Set Height: 400 (Variable) LeftMouseUpAction=[!SetVariable WebH (#WebH#=560?400:560)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetX] Meter=String MeterStyle=StyleButtonText Text=Set X: 320 (Variable) LeftMouseUpAction=[!SetVariable WebX (#WebX#=300?320:300)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetY] Meter=String MeterStyle=StyleButtonText Text=Set Y: 50 (Variable) LeftMouseUpAction=[!SetVariable WebY (#WebY#=45?50:45)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetZoom] Meter=String MeterStyle=StyleButtonText Text=Set ZoomFactor: 0.5 (Variable) LeftMouseUpAction=[!SetVariable ZoomFactor (#ZoomFactor#=1?0.5:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetEnableClickThrough] Meter=String MeterStyle=StyleButtonText Text=Set ClickThrough: 1 (Variable) LeftMouseUpAction=[!SetVariable ClickThrough 1][!UpdateMeasure WebView] [TxtSetDisableClickThrough] Meter=String MeterStyle=StyleButtonText Text=Set ClickThrough: 0 (Variable) LeftMouseUpAction=[!SetVariable ClickThrough 0][!UpdateMeasure WebView] [TxtSetEnableAllowDualControl] Meter=String MeterStyle=StyleButtonText Text=Set AllowDualControl: 1 (Variable) LeftMouseUpAction=[!SetVariable AllowDualControl 1][!UpdateMeasure WebView] [TxtSetDisableAllowDualControl] Meter=String MeterStyle=StyleButtonText Text=Set AllowDualControl: 0 (Variable) LeftMouseUpAction=[!SetVariable AllowDualControl 0][!UpdateMeasure WebView] [TxtSetEnableOpenNewWindow] Meter=String MeterStyle=StyleButtonText Text=Set AllowNewWindow: 1 (Variable) LeftMouseUpAction=[!SetVariable AllowNewWindow 1][!UpdateMeasure WebView] [TxtSetDisableOpenNewWindow] Meter=String MeterStyle=StyleButtonText Text=Set AllowNewWindow: 0 (Variable) LeftMouseUpAction=[!SetVariable AllowNewWindow 0][!UpdateMeasure WebView]Please test and let me know what you guys think.
- WebView waiting:
Sure, I will test it as soon as I come back from work.
Reacted by RicardoTM05Sure, I will test it as soon as I come back from work.
While you're at it, can you also please share if you can drag the skin from a Youtube video area in various plugin versions (i.e. your 0.0.7 one, and the version posted by Ricardo above - see if they both work or not)? Me and Ricardo have been talking a bit on this topic and what happens is that for him none of the versions can do that, while for me yours works without issues while his need a page reload or coming from Google instead of say Bing when navigating to Youtube. We're not sure what causes it since so far it only happens on YT and my downgraded runtime is the only one able to workaround this or have no issues (if the issue is the runtime version, that is - personally, I have serious doubts on that).
Sure, I will test it as soon as I come back from work.
While you're at it, can you also please share if you [...]
I’m unable to drag skin on the YouTube site in both versions.By pressing CTRL key.
Sure, I will test it as soon as I come back from work.
While you're at it, can you also please share if you [...]
I’m unable to drag content on the YouTube site in both versions.By pressing CTRL key.
Thanks! That's interesting indeed - looks like I'm the only one able to do so in both versions, for whatever reason...
Opening the skin context menu with Ctrl + RMB is also not working in the Yt.
I think the best approach for AllowDualControl is to detect the Ctrl key press using keyboard hooks and then forward the click-through to the WebView window.
Opening the skin context menu with Ctrl + RMB is also not working in the Yt.
Yes, those two are more or less related (i.e. usually solving one will solve the other).
I think the best approach for AllowDualControl is to detect the Ctrl key press using keyboard hooks and then forward the click-through to the WebView window.
You mean doing that internally without any Javascript - a combination of your Clickthrough option principle, only triggered by pressing the CTRL key? If so, Ricardo was saying roughly the same thing, but he worded it differently and I was worried that we'd make the plugin a soup of unrelated things to WebView itself. However, If it's possible to do so without any injected script and it doesn't have side effects (like, I don't know, disable any browser / page features potentially relying on pressing the CTRL key; extensive testing would help here), then I'm all for it - forwarding it to the skin window itself, if possible, could be a possibility too. That would require infallible identification of the said the window (even if multiple in the same skin, or even having the same coordinates and dimensions there), but if feasible it would save the need to update the plugin to "fix" any issues with it appearing later on, and still allow for custom dual control via ExecuteScript if desired.
Side note, Ricardo suggested that I should try upgrading my downgraded Edge / WebView2 versions. I'm open to it mostly out of curiosity, and made plans for reverting it in case it goes sideways, but first I'd like to ask you if you think it's a good idea. What I mean by this is that as of now it seems I'm the only one able to check the backward compatibility of the plugin (with all the advantages / disadvantages of it, see the earlier report related to YT drag working on my side in both versions of the plugin), thus when I upgrade, that possibility and the reports from such a system (which could be helpful for the plugin itself) could be missing. What's your stance on this, as the main developer?
You mean doing that internally without any Javascript [......]
I would like this plugin to work with all WebView runtime versions, so I believe Ricardo should adopt the functionality I mentioned.
I would like this plugin to work with all WebView runtime versions [...]
Same here - let's see how your and Ricardo's ideas fit together, since, as I said, he thought about a similar thing as you did (in principle, not sure about the technical details of it).
I was telling Ying that we could use both a keyboard and mouse hook for AllowDualControl instead of pure JS, may be more reliable. I haven’t planned on how to implement it yet though. However only if we don’t find a fix for the current implementation, I’m doing other things.
About the WebView sdk version, my plan is to upgrade it to the newest version so I can use all available methods possible for user settings. And once everything’s done downgrade it to the lowest version possible that contains all methods being used.
Any comments on the test build I shared btw?
Any comments on the test build I shared btw?
Everything I tried seems to work nicely. I only briefly tested the permissions skin, but it works as well - I like it. For now, the GoHome command bang doesn't seem to be such a bad idea, I like it too - but yeah, I didn't go into more complex scenarios to notice any potential shortcommings. Overall, I'm quite pleased with the test build from a user perspective. I only had one surprise when trying to enter an incomplete URL and nothing happened, but that's no problem - the user can regex and substitute stuff himself if he wants some kind of autocompletion, e.g. "rainmeter.net" to "https://rainmeter.net", I don't think we (well, you, to be fair) should bother with that, let them customize that to their liking instead of doing everything for them in that regard.
Reacted by RicardoTM05I don't think we (well, you, to be fair) should bother with that, let them customize that to their liking instead of doing everything for them in that regard.
About that, the URL option does check for valid URLs, this was already done by nstechbytes and remains untouched.
Basically, it first checks if the URL has a valid protocol (http://,https://,file://, etc). If it has a valid protocol then it passes it normally.
If it has no protocol then it is treated as a relative path, so it converts it to an absolute path and addsfile:///.
So, ifURL=googleit will be translated tofile:///C:/Users/User/Documents/Rainmeter/WebView2/BangCommand/google
You can actually enter:URL=#@#Calendar/Index.htmland it will automatically addfile:///to it as well.This only applies to the URL option though, not to the navigate commands. When you enter an empty string to the navigate command it simply doesn't navigate. If you enter a string without a valid protocol nothing will happen either (this is normal Navigate command behavior). So yeah, they can simply create their own logic to handle URLs for navigation.
8 remaining items
Oh ok, so this was added because the
Disabledoption couldn't fully "disable" WebView for when you'd need it - all clear now for me, I'm ok with having it, but maybe it should be implemented / worded / explained in simpler terms once and if it gets to a release version, otherwise we'd have questions on that from the users.Reacted by RicardoTM05Alright, this new build introduces fixes to inject RainmeterAPI to top-level iframes, and a new action and 2 states.
States
- WebView Failed -
-2
When WebView fails for whatever reason, this will be the number returned by the measure. - DOM Content Loaded -
300
This state number was previously for Navigation Complete. - Navigation Complete -
400
Navigation complete is now400
Actions
OnDOMContentLoadAction
This action will trigger when the DOM content finishes loading, it triggers beforeOnPageLoadFinishAction.
Other Changes
- Now RainmeterAPI will be injected on all top-level iframes.
- Implemented AdditionalAllowedFrameAncestors which allows to Ignore X-Frame-Options to render a webpage inside of a frame (requires http-server).
ExecuteScriptcommand will now also inject to top-level frames.
Notes
- Top-level iframes are those that are created by the main document. This means that we can't use RainmeterAPI on iframes that are created inside another iframe, which are called nested iframes.
- A
http-serveris required to frame websites due tofile://scheme lacking the ability to send HTTP-Headers, this is well, because HTTP is a different protocol than file, which is not a network scheme. ExecuteScriptwill inject the same script to the main document and all top-level frames found. A newExecuteScriptOnFramescommand could be implemented to let the user choose, but not completely necessary as the user can design their script to only be injected if the current document is not part of an iframe, or the other way around. Let me know what are your thoughts about this.
Testing
Here's the new testing build.[Deleted]
Click on
Execute Scriptbutton onBangCommand.inito inject text to all available documents.BangCommand.ini
[Rainmeter] Update=-1 AccurateText=1 DynamicWindowSize=1 [Metadata] Name=BangCommand Author=nstechbytes Information=Demonstrates controlling WebView2 via !CommandMeasure bangs. Version=0.0.7 License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0 [Variables] W=920 H=660 HomeURL=https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_height_width WebW=600 WebH=590 WebX=300 WebY=45 AutoStart=1 ZoomFactor=1 Hidden=0 ClickThrough=0 AllowDualControl=1 AllowNewWindow=0 ; ======================================== ; Measure ; ======================================== [WebView] Measure=Plugin Plugin=WebView2 AutoStart=#AutoStart# URL=#HomeURL# W=#WebW# H=#WebH# X=#WebX# Y=#WebY# ZoomFactor=#ZoomFactor# Hidden=#Hidden# ClickThrough=#ClickThrough# AllowDualControl=#AllowDualControl# AllowNewWindow=#AllowNewWindow# OnWebViewLoadAction=[!log "WebView loaded succesfully!"] OnWebViewFailAction=[!log "WebView failed :("] OnStateChangeAction=[!UpdateMeasure #CURRENTSECTION#] OnUrlChangeAction=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter CurrentURL][!Redraw] OnPageFirstLoadAction=[!log "First time on this page!"] OnPageLoadStartAction=[!log "Navigation has started!"] OnPageLoadingAction=[!log "Page is loading!"] OnDOMContentLoadAction=[!log "DOM content loaded!"] OnPageLoadFinishAction=[!log "Navigation has finished!"] OnPageReloadAction=[!log "Page has been reloaded!"] ; These conditions change the State meter text and update it. IfCondition=WebView = -1 IfTrueAction=[!SetOption State Text "Not Running (-1)"][!UpdateMeter State][!Redraw] IfCondition2=WebView = 0 IfTrueAction2=[!SetOption State Text "Initializing... (0)"][!UpdateMeter State][!Redraw] IfCondition3=WebView = 1 IfTrueAction3=[!SetOption State Text "Initialized (1)"][!UpdateMeter State][!Redraw] IfCondition4=WebView = 100 IfTrueAction4=[!SetOption State Text "Navigation Started (100)"][!UpdateMeter State][!Redraw] IfCondition5=WebView = 200 IfTrueAction5=[!SetOption State Text "Loading Site... (200)"][!UpdateMeter State][!Redraw] IfCondition6=WebView = 300 IfTrueAction6=[!SetOption State Text "DOM Content Loaded (300)"][!UpdateMeter State][!Redraw] IfCondition7=WebView = 400 IfTrueAction7=[!SetOption State Text "Navigation Complete (400)"][!UpdateMeter State][!Redraw] IfCondition8=WebView = -2 IfTrueAction8=[!SetOption State Text "Error: Check log for more info (-2)"][!UpdateMeter State][!Redraw] DynamicVariables=1 [UrlInput] Measure=Plugin Plugin=InputText SolidColor=25,25,25 FontColor=255,255,255,255 FontSize=8 X=[&CurrentUrl:X] Y=[&CurrentUrl:Y] W=[&CurrentUrl:W] H=[&CurrentUrl:H] DefaultValue=[&WebView] Command1=[!CommandMeasure WebView "Navigate $UserInput$"] DynamicVariables=1 ; ======================================== ; Background ; ======================================== [Background] Meter=Shape Shape=Rectangle 0,0,#W#,#H#,12 | FillColor 0,0,0,200 | StrokeWidth 0 [Title] Meter=String Text=Bang Command Demo FontSize=16 FontColor=255,255,255,255 AntiAlias=1 X=25 Y=10 [State] Meter=String FontSize=8 FontColor=255,255,255,255 AntiAlias=1 StringAlign=LeftCenter ClipString=1 X=#WebX# Y=13 W=#WebW# DynamicVariables=1 [CurrentUrl] Meter=String MeasureName=WebView FontSize=8 FontColor=255,255,255,255 AntiAlias=1 StringAlign=LeftCenter ClipString=1 SolidColor=25,25,25 Padding=5,0,0,0 X=#WebX# Y=35 W=(#WebW#-5) H=20 LeftMouseUpAction=[!CommandMeasure "UrlInput" "ExecuteBatch 1"] [StyleButtonText] FontColor=255,255,255,255 FontSize=12 AntiAlias=1 W=250 H=25 X=150 Y=3R StringAlign=CenterCenter SolidColor=0,200,255,150 ; ======================================== ; Navigate to URL (Dynamic Variables) ; ======================================== [TxtGoHome] Meter=String MeterStyle=StyleButtonText Text=Go Home Y=58 LeftMouseUpAction=[!CommandMeasure WebView "GoHome"] [TxtNavigateGitHub] Meter=String MeterStyle=StyleButtonText Text=Navigate to GitHub LeftMouseUpAction=[!CommandMeasure WebView "Navigate https://github.com"] [TxtNavigateForum] Meter=String MeterStyle=StyleButtonText Text=Navigate to Forum LeftMouseUpAction=[!CommandMeasure WebView "Navigate https://forum.rainmeter.net/"] [TxtReload] Meter=String MeterStyle=StyleButtonText Text=Reload LeftMouseUpAction=[!CommandMeasure WebView "Reload"] [TxtStop] Meter=String MeterStyle=StyleButtonText Text=Stop LeftMouseUpAction=[!CommandMeasure WebView "Stop"] [TxtGoBack] Meter=String MeterStyle=StyleButtonText Text=Go Back W=122 H=24 X=86 LeftMouseUpAction=[!CommandMeasure WebView "GoBack"] [TxtGoForward] Meter=String MeterStyle=StyleButtonText Text=Go Forward W=125 H=24 X=4R Y=r LeftMouseUpAction=[!CommandMeasure WebView "GoForward"] [TxtStart] Meter=String MeterStyle=StyleButtonText Text=Start WebView LeftMouseUpAction=[!CommandMeasure WebView "WebViewStart"] [TxtTerminate] Meter=String MeterStyle=StyleButtonText Text=Stop WebView LeftMouseUpAction=[!CommandMeasure WebView "WebViewStop"] [TxtRestart] Meter=String MeterStyle=StyleButtonText Text=Restart WebView LeftMouseUpAction=[!CommandMeasure WebView "WebViewRestart"] [TxtExecuteScript] Meter=String MeterStyle=StyleButtonText Text=Execute Script LeftMouseUpAction=[!CommandMeasure WebView """ExecuteScript (() => {const content = document.createElement("h1");content.style.color = "blue";content.textContent = `This is ${window.frameElement ? window.frameElement.name || window.location.href : document.title }`;document.body.prepend(content); alert(`Text will be injected to ${window.frameElement ? window.frameElement.name || window.location.href : document.title }`)})();"""] ;[!CommandMeasure WebView "ExecuteScript alert('Alert has been executed.')"] [TxtOpenDevTools] Meter=String MeterStyle=StyleButtonText Text=Open DevTools LeftMouseUpAction=[!CommandMeasure WebView "OpenDevTools"] [AutoStart] Meter=String MeterStyle=StyleButtonText Text=Set AutoStart: #AutoStart# LeftMouseUpAction=[!SetVariable AutoStart (#AutoStart#=1?0:1)][!WriteKeyValue Variables AutoStart [#AutoStart]][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtHidden] Meter=String MeterStyle=StyleButtonText Text=Set Hidden: #Hidden# LeftMouseUpAction=[!SetVariable Hidden (#Hidden#=1?0:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetWidth] Meter=String MeterStyle=StyleButtonText Text=Set Width: #WebW# LeftMouseUpAction=[!SetVariable WebW (#WebW#=600?500:600)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetHeight] Meter=String MeterStyle=StyleButtonText Text=Set Height: #WebH# LeftMouseUpAction=[!SetVariable WebH (#WebH#=590?400:590)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetX] Meter=String MeterStyle=StyleButtonText Text=Set X: #WebX# LeftMouseUpAction=[!SetVariable WebX (#WebX#=300?320:300)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetY] Meter=String MeterStyle=StyleButtonText Text=Set Y: #WebY# LeftMouseUpAction=[!SetVariable WebY (#WebY#=45?50:45)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetZoom] Meter=String MeterStyle=StyleButtonText Text=Set ZoomFactor: #ZoomFactor# LeftMouseUpAction=[!SetVariable ZoomFactor (#ZoomFactor#=1?0.5:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetClickThrough] Meter=String MeterStyle=StyleButtonText Text=Set ClickThrough: #ClickThrough# LeftMouseUpAction=[!SetVariable ClickThrough (#ClickThrough#=1?0:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetAllowDualControl] Meter=String MeterStyle=StyleButtonText Text=Set AllowDualControl: #AllowDualControl# LeftMouseUpAction=[!SetVariable AllowDualControl (#AllowDualControl#=1?0:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1 [TxtSetOpenNewWindow] Meter=String MeterStyle=StyleButtonText Text=Set AllowNewWindow: #AllowNewWindow# LeftMouseUpAction=[!SetVariable AllowNewWindow (#AllowNewWindow#=1?0:1)][!UpdateMeasure WebView][!UpdateMeter #CURRENTSECTION#][!Redraw] DynamicVariables=1Here's an image of how framing two websites on a single page looks like:

- WebView Failed -
I think I’ve added enough features to start a pull request. What you guys think? I can start committing tomorrow for you to check the code while @Yincognyto adjusts AllowDualControl’s script to account for iframes positions.
I can continue afterwards. I want to start playing with general user settings and environment options, but I think it would be better for another update after this one.
By the way, I will also enable put_allowhostinginputprocessing, well, I already did actually lol, I believe that option will let the plugin read mouse and keyboard input before reaching WebView, allowing us to implement AllowDualControl.
RicardoTM, have you tried setting up a keyboard hook at the plugin level?
I did and failed, but that was before enabling the feature I mentioned. Maybe with that enabled the hooks will work. Will have to try.
Mmm, I'm still not sure how to get it to work. I'm using a low level hook, which is correctly logging keys as long as the focus is on the skin window. As soon as the focus is on the WebView window it stops logging.
I will leave this for after committing current changes. I'm somewhat clueless on this area. I haven't found an example of using
put_allowhostinputprocessing properly, the option is somewhat new. All examples I've seen is how to enable it but that's not much helpful lolHere's the newest build for the PR.
[Deleted]More information here:
#12 (comment) [Closed]Reacted by NSTechBytesJust to give a heads up before posting a new testing build and a new PR:
The previous PR was closed due to several parts of the code being changed.
We now have a perfectly working way to drag the skin. The reason why I was not being able to use a hook was because of the old UpdateClickthrough function, which was causing the plugin to crash on load or and on unload when a subclass window procedure was used, or even with the hook only.
Once said function was removed I was able to implement both. The low level hook now can monitor the ctrl key state and send a custom message to the subclass win proc of each skin when the key is press or released.
Since I was now able to monitor the key, I rewritten the old UpdateClickthrough function and used it for this, basically when you press ctrl, a soft clickthrough state is enabled which lets the user interact with the meters behind the webview window but without losing keyboard focus so ctrl based hotkeys were still available. While this method lets the user drag the skin and open the skin menu, it doesn’t have anything to do with them as AllowDualControl used to do. So I decided to rename it SkinControl.SkinControl has 4 modes:
- SkinControl 0: Disabled, only lets you interact with WebView.
- SkinControl 1: Only lets you interact with the skin meters and not with WebView.
- SkinControl 2: Lets you interact with the skin meters while ctrl is held.
- SkinControl 3: Lets you interact with the WebView window while ctrl is held.
After some testing, these 4 modes showed to be enough to cover various scenarios.
Since SkinControl now covers all those scenarios, the Clickthrough option was removed as it became redundant.
The PR I will present also includes new options which I will cover soon, it also includes new defaults for options that are still not exposed to the user.
I was working on scripting and frames for this new PR as well, however both proved to need more careful planning to be implemented on a better way, so I decided to delay those features in the hope we can focus only on that in order to plan it carefully and hopefully find a fix for RainmeterAPI not being available on certain sites as well.
That being said, the new PR will focus on SkinControl, the measure’s string and number values rework, and a few new options which I hope will enhance WebView’s customization.
Last but not least, it will also include a new feature called VirtualHost which will be very useful to replace the need of an external http-server in certain situations.
New PR has been created: v.0.0.8: Reworks, Options and Settings. There you will find details.
Since most example skins were modified, A .rmskin package is included this time.
Removed
Current options and defaults
[WebView2] Measure=Plugin Plugin=WebView2 ; Virtual Host & Navigation Options HostSecurity=1 HostOrigin=1 HostPath="" URL="" ; Window Options W=800 H=600 X=0 Y=0 ZoomFactor=1.0 Hidden=0 Clickthrough=2 ; WebView Options AutoStart=1 ;Browser Options UserAgent="" ZoomControl=1 NewWindow=0 Notifications=0 AssistiveFeatures=1 ; WebView State Actions OnWebViewLoadAction=[] OnWebViewFailAction=[] OnWebViewStopAction=[] ; Navigation State Actions OnStateChangeAction=[] OnUrlChangeAction=[] OnPageLoadStartAction=[] OnPageLoadingAction=[] OnPageDOMLoadAction=[] OnPageFirstLoadAction=[] OnPageReloadAction=[] OnPageLoadFinishAction=[] --- ; WebView Commands [!CommandMeasure WebView2 "WebView Start"] [!CommandMeasure WebView2 "WebView Stop"] [!CommandMeasure WebView2 "WebView Restart"] ; Navigation Commands [!CommandMeasure WebView2 "Navigate Home"] [!CommandMeasure WebView2 "Navigate Back"] [!CommandMeasure WebView2 "Navigate Forward"] [!CommandMeasure WebView2 "Navigate Reload"] [!CommandMeasure WebView2 "Navigate Stop"] [!CommandMeasure WebView2 "Navigate http://www.example.com"] ; External Tools Commands [!CommandMeasure WebView2 "Open DevTools"] [!CommandMeasure WebView2 "Open TaskManager"] ; Scripting Commands [!CommandMeasure WebView2 "ExecuteScript alert('Example script')"] ;Section Variables [WebView2:CallJS('alert("Example script")')] ;User Data Folder Path C:\Users\User\AppData\Local\Temp\RainmeterWebView2\Current options and defaults
Now that you listed all options and commands, they don't seem that many after all, even with potential frame / script options...
they don't seem that many after all
There’s room
Current status for v1.1.0
Following the security recommendations on the other issue:
- Added
ApiAccessEnablesRainmeterAPI(disabled by default) - Added
FileAccessAllows file:// and virtual hosts to read and write files using the File System API without requiring permission. Any other site will ask for permission as normal. (Disabled by default) - Added
Open in default browserto the context menu. - The WebView window now correctly resizes when
Zoomis used on a skin and correctly reacts to changes ondpi(for Rainmeter 5.0, it has no effect on earlier versions). - Now virtual hosts hostname will append
.rmto the generated url (rmmeans rainmeter). For example,https://rootconfig/index.htmlwill now behttps://rootconfig.rm/index.html. This fixes the 2-second delay seen when using the virtual host feature. Unfortunately, since the origin is now different, users usingLocalStorageorIndexedDBor any other feature that applies to a certain origin will experience a data "loss". - Errors that were logged when a command was called while the plugin was not running are now warnings. Also added more information to the logs to avoid confusion.
- The
UDFwill now be created inside Rainmeter’s plugins folder. It used to be created on the temp folder, which would eventually cause the user settings to be deleted.
Testing build:
WebView2_v1.0.8_x64_x86_dll.zip- Added
Thanks, Ricardo!
Reacted by RicardoTM05
Hey @NSTechBytes @Yincognyto, I open this issue only to have a public place where to have a conversation about new features and share testing builds. This is to have it public but private enough to avoid sharing the test builds directly on the forums where is more broadly public, I don't like the idea of having bugged/non working versions publicly available on the forums.. Also to avoid creating pull requests with many changes.
Current test package here: #9 (comment)