Skip to content

RicardoTM05/WebView2

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

80 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WebView2 Plugin for Rainmeter

WebView2 Plugin Banner

Embed modern web content directly into your Rainmeter skins with full JavaScript interactivity

Version License Rainmeter Windows

๐Ÿ“ฅ Download โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ก Examples โ€ข ๐Ÿค Contributing


โœจ What Can You Build?

Clock
Animated Widgets
Create stunning animated clocks, weather displays, and visualizers
Web
Web Dashboards
Embed live web content and interactive dashboards
API
Smart Integrations
Connect to APIs and control Rainmeter with JavaScript

๐ŸŽฏ Key Features

๐Ÿš€ Modern Web Engine

Powered by Microsoft Edge WebView2, supporting:

  • โœ… HTML5, CSS3, JavaScript ES6+
  • โœ… Modern frameworks (React, Vue, Svelte)
  • โœ… WebGL, Canvas, SVG animations
  • โœ… Transparent backgrounds by default
๐Ÿ”Œ Seamless JavaScript Bridge

Two-way communication between web and Rainmeter:

  • โœ… Call Rainmeter API from JavaScript
  • โœ… Execute JavaScript from Rainmeter
  • โœ… Real-time data synchronization
  • โœ… Custom events and callbacks
โšก Dynamic & Flexible
  • โœ… Load local HTML or remote URLs
  • โœ… Multiple WebView instances per skin
  • โœ… Hot-reload without flickering
  • โœ… Developer tools (F12) built-in

๐Ÿ“‹ Requirements

Before you begin, make sure you have:

Requirement Version Status
Windows 10 (1803+) or 11 Windows
Rainmeter 4.5 or higher Rainmeter
WebView2 Runtime Latest WebView2
๐Ÿ“ฆ Don't have WebView2 Runtime?

Good news! Windows 11 includes it by default. For Windows 10:

  1. ๐Ÿ”— Download WebView2 Runtime
  2. ๐ŸŽฏ Choose "Evergreen Standalone Installer"
  3. โšก Run the installer (takes ~1 minute)

๐Ÿ“ฅ Installation

๐ŸŽ Method 1: One-Click Install (Recommended)

The easiest way to get started!

  1. ๐Ÿ“ฆ Download the .rmskin file
  2. ๐Ÿ–ฑ๏ธ Double-click to install
  3. โœจ Done! Plugin and examples are ready to use

Rainmeter will automatically install everything you need

๐Ÿ› ๏ธ Method 2: Manual Installation

Click to expand manual installation steps
  1. Download the plugin DLLs from Releases

  2. Choose the right version:

    ๐Ÿ“ x64/WebView2.dll  โ† For 64-bit Rainmeter (most common)
    ๐Ÿ“ x32/WebView2.dll  โ† For 32-bit Rainmeter
    
  3. Copy to your Rainmeter plugins folder:

    %AppData%\Rainmeter\Plugins\
    
  4. Restart Rainmeter


๐Ÿš€ Quick Start

Your First WebView Skin

Create a new skin with this minimal configuration:

[Rainmeter]
Update=1000

[MeasureWebView]
Measure=Plugin
Plugin=WebView2
URL=file:///#@#index.html
W=800
H=600

Create index.html in your @Resources folder:

<!DOCTYPE html>
<html>
<head>
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-family: 'Segoe UI', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        h1 { font-size: 3em; animation: fadeIn 1s; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    </style>
</head>
<body>
    <h1>๐ŸŽ‰ Hello Rainmeter!</h1>
</body>
</html>

That's it! Load the skin and see your first WebView in action.


โš™๏ธ Configuration Options

Option Description Default Example
URL ๐ŸŒ HTML file or web URL
Supports: file:///, http://, https://
Required file:///#@#index.html
W ๐Ÿ“ Width in pixels 800 1920
H ๐Ÿ“ Height in pixels 600 1080
X โ†”๏ธ Horizontal position offset 0 100
Y โ†•๏ธ Vertical position offset 0 50
Hidden ๐Ÿ‘๏ธ Start hidden
0 = visible, 1 = hidden
0 1
Clickthrough ๐Ÿ–ฑ๏ธ Mouse interaction
0 = interactive, 1 = clickthrough
0 1
DynamicVariables ๐Ÿ”„ Enable live updates 0 1

๐Ÿ’ก Pro Tip: When DynamicVariables=1, the WebView updates smartly:

  • URL changes โ†’ Navigates without recreating
  • Size/Position changes โ†’ Applied instantly, no flicker
  • Visibility changes โ†’ Instant toggle

๐ŸŽฎ Bang Commands

Control your WebView with Rainmeter bangs:

Navigation Commands

; Go to a URL
[!CommandMeasure MeasureWebView "Navigate https://example.com"]

; Reload current page
[!CommandMeasure MeasureWebView "Reload"]

; Browser history
[!CommandMeasure MeasureWebView "GoBack"]
[!CommandMeasure MeasureWebView "GoForward"]

Control Commands

; Execute JavaScript
[!CommandMeasure MeasureWebView "ExecuteScript alert('Hi!')"]

; Developer tools
[!CommandMeasure MeasureWebView "OpenDevTools"]

๐Ÿ”ฅ JavaScript Integration

Lifecycle Hooks

Your JavaScript can respond to Rainmeter events:

// Called once when plugin is ready
window.OnInitialize = function() {
    console.log("๐Ÿš€ WebView initialized!");
    return "Ready!"; // This becomes the measure's value
};

// Called on every Rainmeter update
window.OnUpdate = function() {
    const now = new Date().toLocaleTimeString();
    return now; // Updates measure value
};

โš ๏ธ Note: JavaScript execution is asynchronous, so there's a 1-update delay between JS return and Rainmeter display. This is normal!

Call JavaScript from Rainmeter

Use section variables to call any JavaScript function:

[MeterTemperature]
Meter=String
Text=Current temp: [MeasureWebView:CallJS('getTemperature')]ยฐC
DynamicVariables=1
// In your HTML
window.getTemperature = function() {
    return 72;
};

๐ŸŒ‰ RainmeterAPI Bridge

Access Rainmeter's full power from JavaScript:

Read Skin Options

// Read from your measure
const refreshRate = await RainmeterAPI.ReadInt('UpdateRate', 1000);
const siteName = await RainmeterAPI.ReadString('SiteName', 'Default');

// Read from other sections
const cpuUsage = await RainmeterAPI.ReadStringFromSection('MeasureCPU', 'Value', '0');

Execute Bangs

// Set variables
await RainmeterAPI.Bang('!SetVariable MyVar "Hello World"');

// Control skins
await RainmeterAPI.Bang('!ActivateConfig "MySkin" "Variant.ini"');

// Update meters
await RainmeterAPI.Bang('!UpdateMeter MeterName');
await RainmeterAPI.Bang('!Redraw');

Get Skin Information

const skinName = await RainmeterAPI.SkinName;
const measureName = await RainmeterAPI.MeasureName;

// Replace variables
const path = await RainmeterAPI.ReplaceVariables('#@#images/logo.png');

// Get variable values
const theme = await RainmeterAPI.GetVariable('CurrentTheme');

Logging

await RainmeterAPI.Log('Debug info', 'DEBUG');
await RainmeterAPI.Log('Warning message', 'WARNING');
await RainmeterAPI.Log('Error occurred', 'ERROR');

Complete API Reference

๐Ÿ“š Click to see all available methods

Reading Options

  • ReadString(option, defaultValue) โ†’ Promise<string>
  • ReadInt(option, defaultValue) โ†’ Promise<number>
  • ReadDouble(option, defaultValue) โ†’ Promise<number>
  • ReadFormula(option, defaultValue) โ†’ Promise<number>
  • ReadPath(option, defaultValue) โ†’ Promise<string>

Reading from Sections

  • ReadStringFromSection(section, option, defaultValue) โ†’ Promise<string>
  • ReadIntFromSection(section, option, defaultValue) โ†’ Promise<number>
  • ReadDoubleFromSection(section, option, defaultValue) โ†’ Promise<number>
  • ReadFormulaFromSection(section, option, defaultValue) โ†’ Promise<number>

Utility Functions

  • ReplaceVariables(text) โ†’ Promise<string>
  • GetVariable(variableName) โ†’ Promise<string>
  • PathToAbsolute(relativePath) โ†’ Promise<string>
  • Bang(command) โ†’ Promise<void>
  • Log(message, level) โ†’ Promise<void>

Properties

  • MeasureName โ†’ Promise<string>
  • SkinName โ†’ Promise<string>
  • SkinWindowHandle โ†’ Promise<string>
  • SettingsFile โ†’ Promise<string>

๐Ÿ’ก Examples

The plugin includes ready-to-use example skins:

๐Ÿ• Clock
Animated liquid clock with smooth animations
๐Ÿ“… Calendar
Interactive month view calendar
โš™๏ธ Config Reader
Read options from measures and sections
๐Ÿ”ง Utilities
Demonstrate all API functions

To explore examples:

  1. Install the .rmskin package
  2. Check your Rainmeter skins folder
  3. Load example skins from Rainmeter manager

๐Ÿ› ๏ธ Building from Source

For Developers: Build Instructions

Prerequisites

  • Visual Studio 2022 with C++ desktop development
  • Windows SDK
  • PowerShell 5.1+

Build Steps

# Clone repository
git clone https://github.com/yourusername/WebView2.git
cd WebView2

# Open in Visual Studio
start WebView2-Plugin.sln

# Build with PowerShell
powershell -ExecutionPolicy Bypass -Command "& {. .\Build-CPP.ps1; Dist -major 0 -minor 0 -patch 3}"

Build Output

๐Ÿ“ dist/
  โ”œโ”€โ”€ ๐Ÿ“ x64/
  โ”‚   โ””โ”€โ”€ WebView2.dll
  โ”œโ”€โ”€ ๐Ÿ“ x32/
  โ”‚   โ””โ”€โ”€ WebView2.dll
  โ”œโ”€โ”€ WebView2_v0.0.3_x64_x86_dll.zip
  โ””โ”€โ”€ WebView2_v0.0.3_Alpha.rmskin

๐Ÿ†˜ Troubleshooting

โŒ "WebView2 Runtime is not installed"

Solution: Install WebView2 Runtime

Windows 11 has it pre-installed. For Windows 10, download and run the installer.

โŒ "Failed to create WebView2 controller"

Try these steps:

  1. โœ… Right-click skin โ†’ Refresh skin
  2. โœ… Restart Rainmeter completely
  3. โœ… Verify WebView2 Runtime is installed
  4. โœ… Check Windows Event Viewer for detailed errors
โŒ "RainmeterAPI is not defined" in JavaScript

Solution: Wait for page to load before accessing API:

document.addEventListener('DOMContentLoaded', () => {
    // Now you can use RainmeterAPI
    RainmeterAPI.Log('Page loaded!', 'DEBUG');
});
โŒ WebView not visible

Checklist:

  • โœ… Ensure Hidden=0 in your measure (default is 0)
  • โœ… Check URL path is correct
  • โœ… Verify HTML file exists
  • โœ… Look for errors in Rainmeter log
  • โœ… Try: [!CommandMeasure MeasureName "OpenDevTools"] to debug

Transparency tip: The WebView has transparent background by default. Use background: transparent; in your CSS.


๐Ÿ“„ License

MIT License - Free to use, modify, and distribute

See LICENSE file for full details


๐Ÿค Contributing

We welcome contributions! Here's how:

1. Fork
๐Ÿด
Fork this repo
2. Branch
๐ŸŒฟ
Create feature branch
3. Code
๐Ÿ’ป
Make your changes
4. Commit
๐Ÿ“
Commit with clear message
5. PR
๐Ÿš€
Open Pull Request
git checkout -b feature/AmazingFeature
git commit -m 'Add some AmazingFeature'
git push origin feature/AmazingFeature

๐Ÿ™ Acknowledgments

Built with powerful tools and inspired by the community

Microsoft Edge WebView2 โ€ข Rainmeter API โ€ข Rainmeter Community


๐Ÿ’– Made with love for the Rainmeter community

โฌ† Back to Top

Made with Love

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 40.6%
  • CSS 18.3%
  • PowerShell 14.6%
  • JavaScript 14.1%
  • HTML 12.1%
  • C 0.3%