Skip to content

Instantly share code, notes, and snippets.

@modster
Created December 16, 2021 23:50
Show Gist options
  • Save modster/e36afa511c01d3b22db1c1437a3c9f38 to your computer and use it in GitHub Desktop.
Save modster/e36afa511c01d3b22db1c1437a3c9f38 to your computer and use it in GitHub Desktop.
BrowserWindowTransparency
<!DOCTYPE html>
<html lang="en">
<head>
<title>BrowserWindow</title>
</head>
<body>
<h1>Hello from your BrowserWindow!</h1>
<button id="close-btn">Close this window</button>
<script>
const button = document.querySelector('#close-btn')
button.addEventListener('click', () => window.close())
</script>
</body>
</html>
// The "BrowserWindow" class is the primary way to create user interfaces
// in Electron. A BrowserWindow is, like the name suggests, a window.
//
// For more info, see:
// https://electronjs.org/docs/api/browser-window
const { app, BrowserWindow } = require('electron')
const windows = []
app.whenReady().then(() => {
// BrowserWindows can be created in plenty of shapes, sizes, and forms.
// Check out the editor's auto-completion for all the configuration
// options available in the current version.
//
// Let's make a few windows!
// A window that's only half visible
windows.push(
new BrowserWindow({
opacity: 0.5,
x: 200,
y: 200
})
)
// A transparent window.
const windowOptions = {
transparent: true,
x: 300,
y: 300
}
// On Windows platforms, a transparent window must be frameless
if (process.platform === 'win32') {
windowOptions.frame = false
}
windows.push(new BrowserWindow(windowOptions))
// A window that's fixed and always on top
windows.push(
new BrowserWindow({
movable: false,
resizable: false,
alwaysOnTop: true,
maximizable: false,
minimizable: false,
x: 600,
y: 600
})
)
windows.forEach((window) => {
// Load our index.html
window.loadFile('index.html')
})
})
{
"name": "nonchalant-kitty-deceive-5k4q9",
"productName": "nonchalant-kitty-deceive-5k4q9",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "unmod",
"scripts": {
"start": "electron ."
},
"dependencies": {
"node-binance-api": "*"
},
"devDependencies": {
"electron": "16.0.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment