Skip to content

Commit ab008f6

Browse files
committed
Add WebView2 Rainmeter plugin with bang command support and an example skin.
1 parent 43f1363 commit ab008f6

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

Build-CPP.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#usage -----> powershell -ExecutionPolicy Bypass -Command "& {. .\Build-CPP.ps1; Dist -major 0 -minor 0 -patch 5}"
1+
#usage -----> powershell -ExecutionPolicy Bypass -Command "& {. .\Build-CPP.ps1; Dist -major 0 -minor 0 -patch 6}"
22
$msbuild = "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"
33

44
function Add-RMSkinFooter {

Resources/Skins/WebView2/BangCommand/BangCommand.ini

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
1313
[Variables]
1414
WebURL=https://nstechbytes.pages.dev/
1515
WebW=600
16-
WebH=350
16+
WebH=410
1717
WebX=300
18-
WebY=25
18+
WebY=45
1919
Hidden=0
20+
ClickThrough=0
2021
; ========================================
2122
; Measure
2223
; ========================================
@@ -29,14 +30,15 @@ H=#WebH#
2930
X=#WebX#
3031
Y=#WebY#
3132
Hidden=#Hidden#
33+
ClickThrough=#ClickThrough#
3234
DynamicVariables=1
3335

3436
; ========================================
3537
; Background
3638
; ========================================
3739
[MeterBackground]
3840
Meter=Shape
39-
Shape=Rectangle 0,0,950,420,12 | FillColor 0,0,0,200 | StrokeWidth 0
41+
Shape=Rectangle 0,0,950,480,12 | FillColor 0,0,0,200 | StrokeWidth 0
4042

4143
[Title]
4244
Meter=String
@@ -179,5 +181,20 @@ X=150
179181
Y=388
180182
LeftMouseUpAction=[!SetVariable WebY 50][!UpdateMeasure MeasureWebView][!Redraw]
181183

184+
[TxtSetEnableClickThrough]
185+
Meter=String
186+
MeterStyle=StyleButtonText
187+
Text=Set ClickThrough: 1 (via Variable)
188+
X=150
189+
Y=418
190+
LeftMouseUpAction=[!SetVariable ClickThrough 1][!UpdateMeasure MeasureWebView][!Redraw]
191+
192+
[TxtSetDisableClickThrough]
193+
Meter=String
194+
MeterStyle=StyleButtonText
195+
Text=Set ClickThrough: 0 (via Variable)
196+
X=150
197+
Y=448
198+
LeftMouseUpAction=[!SetVariable ClickThrough 0][!UpdateMeasure MeasureWebView][!Redraw]
182199

183200

WebView2/Plugin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ void UpdateClickthrough(Measure* measure)
114114
// EnableWindow(FALSE) makes it ignore mouse input (Clickthrough=1)
115115
// EnableWindow(TRUE) makes it accept mouse input (Clickthrough=0)
116116
EnableWindow(child, !measure->clickthrough);
117+
118+
// If enabling clickthrough (disabling input), ensure it loses focus
119+
if (measure->clickthrough)
120+
{
121+
HWND focusedWindow = GetFocus();
122+
if (focusedWindow && (focusedWindow == child || IsChild(child, focusedWindow)))
123+
{
124+
SetFocus(nullptr);
125+
}
126+
}
117127

118128
child = GetWindow(child, GW_HWNDNEXT);
119129
}

0 commit comments

Comments
 (0)