Windows
Any kind of actions relating to managing a window or it's lifecycle. This also includes properties of the window's web contents. In Electron's docs, these are separate modules. However, in our adaptation, these are combined for simplicity.
At least one window must exist at all times. If all windows are closed/become unresponsive, the app will close. For apps intended to be background apps, consider using the skipTaskbar property.
Methods
Create Window
Creates a new window.
await window.deskifier.windows.create({ arguments })
Arguments
constructorOptionsDeskifier.constructorOptions — see the constructorOptions object belowwindowPropertiesDeskifier.windowProperties — see the windowProperties object below
Returns
windowIdStringsuccessBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const constructorOptions = {
url: "https://www.deskifier.com",
show: false,
center: true,
frame: false
};
const windowProperties = {
resizable: true,
width: 800,
height: 600,
alwaysOnTop: true,
title: "Fresh Window"
};
const result = await window.deskifier.windows.create({
constructorOptions,
windowProperties,
});
console.log(result.windowId); // "window-2"
Update Window Properties
Updates the window properties.
Note: Fields are optional. Only properties that are provided will be updated; omitted properties will remain unchanged.
await window.deskifier.windows.updateProperties({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.windowPropertiesDeskifier.windowProperties — see the windowProperties object below
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const options = {
resizable: true,
width: 800,
height: 600,
alwaysOnTop: true,
title: "Updated Window"
};
const result = await window.deskifier.windows.updateProperties({
windowId: "window-1",
windowProperties: options,
});
console.log(result.success); // true
Destroy Window
Destroys the window. If this is the only window open, the app will close. If you wish to continue running in the background, you should hide the window and skip the taskbar.
await window.deskifier.windows.destroy({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Center Window
Centers the window in the middle of the screen.
await window.deskifier.windows.center({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Focus Window
Focuses on the window.
await window.deskifier.windows.focus({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Blur Window
Unfocuses the window.
await window.deskifier.windows.blur({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Show Window
Shows and gives focus to the window.
await window.deskifier.windows.show({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Hide Window
Hides the window.
await window.deskifier.windows.hide({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Maximize Window
Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already.
await window.deskifier.windows.maximize({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Unmaximize Window
Unmaximizes the window.
await window.deskifier.windows.unmaximize({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Minimize Window
Minimizes the window. On some platforms the minimized window will be shown in the Dock.
await window.deskifier.windows.minimize({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Restore Window
Restores the window from minimized state to its previous state.
await window.deskifier.windows.restore({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Reload Web Contents
Reloads the current web contents.
await window.deskifier.windows.reload({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Toggle Dev Tools
Show/hide the dev tools.
await window.deskifier.windows.toggleDevTools({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.showBoolean (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Navigate Back
Goes back a page, if possible.
await window.deskifier.windows.navigateBack({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Navigate Forward
Goes forward a page, if possible.
await window.deskifier.windows.navigateForward({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Execute JavaScript
Executes JavaScript in the specified window.
await window.deskifier.windows.executeJavaScript({ arguments })
Arguments
windowIdString (Required)codeString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Start Drag
Sets the dragging item for the current drag-drop operation.
await window.deskifier.windows.startDrag({ arguments })
Arguments
filePathsArray of Strings
The paths to the files being dragged. Can be a single file path, or multiple.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Send Window Message
Sends a custom message that can be received by another window. This will fire the 'windowMessageReceived' event in the target window.
await window.deskifier.windows.sendMessage({ arguments })
Arguments
toWindowIdString (Required)messageString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Properties
Get All Window IDs
Returns all available window IDs
await window.deskifier.windows.getAllIds()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.windowIdsArray Of Strings
Get Window Properties
Returns an object with the current state of the window.
await window.deskifier.windows.getProperties({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.windowPropertiesDeskifier.WindowProperties
Get Web Contents Properties
Returns an object with details about the window's web contents object.
await window.deskifier.windows.getWebContentsProperties({ arguments })
Arguments
windowIdString (Optional)
Defaults to the current window.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.webContentsDeskifier.webContentsProperties
Events
Window Closed
Emitted when a window is closed.
window.deskifier.windows.onClosed((data) => {})
Arguments
windowIdString
Example
window.deskifier.windows.onClosed((data) => {
console.log(data.windowId);
});
//2
Window Close Attempt
Emitted when a user attempts to close a window, but the window is not closable.
window.deskifier.windows.onCloseAttempt((data) => {})
Arguments
windowIdString
Window Unresponsive
Emitted when a window's webpage becomes unresponsive.
window.deskifier.windows.onUnresponsive((data) => {})
Arguments
windowIdString
Window Responsive
Emitted when a window's webpage becomes responsive again.
window.deskifier.windows.onResponsive((data) => {})
Window Blurred
Fires when a browser window is unfocused.
window.deskifier.windows.onBlurred((data) => {})
Arguments
windowIdString
Window Focused
Fires when a browser window is focused.
window.deskifier.windows.onFocused((data) => {})
Arguments
windowIdString
Window Shown
Fires when a browser window is shown.
window.deskifier.windows.onShown((data) => {})
Arguments
windowIdString
Window Hidden
Fires when a browser window is hidden.
window.deskifier.windows.onHidden((data) => {})
Arguments
windowIdString
Window Ready To Show
Fires when a browser window is loaded, and rendered. Use this to show a window gracefully.
window.deskifier.windows.onReadyToShow((data) => {})
Arguments
windowIdString
Window Maximized
Fires when a browser window is maximized.
window.deskifier.windows.onMaximized((data) => {})
Arguments
windowIdString
Window Unmaximized
Fires when a browser window is unmaximized.
window.deskifier.windows.onUnmaximized((data) => {})
Arguments
windowIdString
Window Minimized
Fires when a browser window is minimized.
window.deskifier.windows.onMinimized((data) => {})
Arguments
windowIdString
Window Restored
Fires when a browser window is restored.
window.deskifier.windows.onRestored((data) => {})
Arguments
windowIdString
Window Resized
Fires when a browser window is resized.
window.deskifier.windows.onResized((data) => {})
Arguments
windowIdString
Window Moved
Fires when a browser window is moved.
window.deskifier.windows.onMoved((data) => {})
Arguments
windowIdString
Window Entered Fullscreen
Fires when a browser window enters fullscreen mode.
window.deskifier.windows.onEnteredFullscreen((data) => {})
Arguments
windowIdString
Window Left Fullscreen
Fires when a browser window leaves fullscreen.
window.deskifier.windows.onLeftFullscreen((data) => {})
Arguments
windowIdString
Window Entered HTML Fullscreen
Fires when a window enters a full-screen state triggered by HTML API.
window.deskifier.windows.onEnteredHTMLFullscreen((data) => {})
Arguments
windowIdString
Window Left HTML Fullscreen
Fires when a window leaves a full-screen state triggered by HTML API.
window.deskifier.windows.onLeftHTMLFullscreen((data) => {})
Arguments
windowIdString
Window Message Received
Fires when a message is received from another window. Send a message with the 'Send Window Message' method.
window.deskifier.windows.onMessageReceived((data) => {})
Arguments
fromWindowIdString
The window ID that generated the message.toWindowIdString
The window ID that the message was sent to.messageString
Files Dropped
Fires when one or more external files are dropped onto the window via the secure drag-and-drop overlay. The paths array contains absolute paths to the dropped files, which are automatically added to the app's filesystem access allowlist so you can read them immediately.
window.deskifier.windows.onFilesDropped((data) => {})
Arguments
pathsArray of Strings
Absolute paths to the files that were dropped.
Example
window.deskifier.windows.onFilesDropped(async (data) => {
for (const path of data.paths) {
const { content } = await window.deskifier.filesystem.readFile({ path });
console.log(path, content.length, 'bytes');
}
});
Objects
windowProperties
widthNumber
Width in px. Default is800.heightNumber
Height in px. Default is600.xNumber
(required if y is used) Window's left offset from screen. Default is to center the window.yNumber
(required if x is used) Window's top offset from screen. Default is to center the window.centerBoolean
Centers the window on screen. Only takes effect whenx/yare not provided.minWidthNumber
Window's minimum width. Default is0.minHeightNumber
Window's minimum height. Default is0.maxWidthNumber
Window's maximum width. Default is no limit.maxHeightNumber
Window's maximum height. Default is no limit.resizableBoolean
Controls if the window is resizable.movableBoolean macOS Windows
Controls if the window can be moved by the user. On Linux does nothing.minimizableBoolean macOS Windows
Controls if the window can be minimized. On Linux does nothing.maximizableBoolean macOS Windows
Controls if the window can be maximized. On Linux does nothing.closableBoolean macOS Windows
Sets if the window can be closed by the user. On Linux does nothing.interceptCloseBoolean
Whentrue, user-initiated close attempts fire thewindowCloseAttemptevent instead of actually closing the window. Useful for showing a "save before closing?" prompt. Default isfalse.alwaysOnTopBoolean
Sets the window to stay on top of other windows.fullscreenBoolean
Whether the window should show in fullscreen. When explicitly set tofalsethe fullscreen button will be hidden or disabled on macOS. Default isfalse.fullscreenableBoolean
Whether the window can be put into fullscreen mode. On macOS, also whether the maximize/zoom button should toggle full screen mode or maximize window. Default istrue.maximizedBoolean
Whether the window is maximized. Setting totruemaximizes the window; setting tofalseunmaximizes it.skipTaskbarBoolean macOS Windows (Optional)
Makes the window not show in the taskbar/dock.falseby default.kioskBoolean
Whether the window is in kiosk mode. Default isfalse.showBoolean
When passed astrueviaupdateWindowProperties, shows the window. For full show/hide control, use the dedicatedshowWindowandhideWindowmethods. (Not to be confused with the read-onlyisVisible.)titleString
Default window title. Default is"Electron". If the HTML tag<title>is defined in the HTML file loaded, this property will be ignored.backgroundColorString
Sets the window’s background color, in hex (e.g., #FFFFFF).hasShadowBoolean
Whether window should have a shadow. Default istrue.opacityNumber macOS Windows
Sets window transparency, range 0.0 (fully transparent) to 1.0 (fully opaque).ignoreMouseEventsBoolean
Ignores or allows mouse events.falseby default.forwardMouseEventsBoolean macOS Windows
WhenignoreMouseEventsis enabled, allows mouse events to be forwarded to underlying elements, to detect events like mouseEnter and mouseLeave.falseby default.visibleOnAllWorkspacesBoolean macOS Linux (Optional)
Set if the window will show up across all workspaces. Useful for utility applications & floating windows.falseby default.trafficLightVisibilityBoolean macOS (Optional)
Set if the traffic lights should be visible.trafficLightPositionPoint macOS
Repositions the traffic light buttons at runtime. Requires the window was created withtitleBarStyle: 'hidden'orpresetTitleBar: 'Custom Overlay'.xNumberyNumber
titleBarOverlayObject Windows Linux
Updates the Window Controls Overlay colors and height at runtime. Requires the window was created withtitleBarStyle: 'hidden'and the overlay enabled (e.g., viapresetTitleBar: 'Overlay').colorString
The CSS color of the overlay.symbolColorString Windows
The CSS color of the button symbols.heightNumber
Height of the title bar in pixels.
vibrancyString macOS
Applies a translucent vibrancy (blur) material to the window background. Possible values:'appearance-based','light','dark','titlebar','selection','menu','popover','sidebar','medium-light','ultra-dark','header','sheet','window','hud','fullscreen-ui','tooltip','content','under-window','under-page'. Passnullto remove.backgroundMaterialString Windows 11
Applies a backdrop material to the window. Possible values:'auto','none','mica','acrylic','tabbed'. Has no effect on Windows 10, macOS, or Linux.isMinimizedBoolean
If the window is currently minimized. Read only.isMaximizedBoolean
If the window is currently maximized. Read only.isNormalBoolean
Whether the window is in normal state (not maximized, not minimized, not in fullscreen mode). Read only.isFocusedBoolean
Whether the window is focused. Read only.isVisibleBoolean
Whether the window is visible to the user in the foreground of the app. Read only.idString
The window's ID. Read only.
constructorOptions
urlString (Required)windowIdString
The window ID of the new window. Must be unique. If a value is not given, one will be generated.showBoolean
Whether to show the window. It's recommended to set this to false, and wait for theready-to-showevent before showing. Default istrue.showAfterLoadingBoolean
Iftrue, the window stays hidden until its content finishes loading, then shows automatically. Overridesshowinternally. Default isfalse.centerBoolean
Show window in the center of the screen. Default isfalse.frameBoolean
Specifyfalseto create a frameless window. Default istrue.transparentBoolean
Makes the window transparent. Default istrue. On Windows, does not work unless the window is frameless. Note, this is not the same as theopacityproperty.presetTitleBarString
A high-level title bar preset. When set, overridesframe,titleBarStyle,titleBarOverlay, andtrafficLightPosition. Possible values:Window Frame— standard OS frame and title bar. (default behavior)None— frameless window with no title bar and no window controls.Overlay— hidden title bar. On macOS shows the standard traffic lights; on Windows/Linux activates the Window Controls Overlay with default colors. You can still providetitleBarOverlayto customize button colors on Windows/Linux.Overlay InsetmacOS — hidden title bar with traffic lights slightly inset from the window edge.Custom Overlay— frameless, hidden title bar, no Window Controls Overlay. Use when rendering your own title bar. On macOS, reposition the traffic lights withtrafficLightPosition.
titleBarStyleString
The style of window title bar. Default isdefault. Possible values are:default- Results in the standard title bar for macOS or Windows respectively.hidden- Results in a hidden title bar and a full size content window. On macOS, the window still has the standard window controls (“traffic lights”) in the top left. On Windows and Linux, when combined withtitleBarOverlay: trueit will activate the Window Controls Overlay (seetitleBarOverlayfor more information), otherwise no window controls will be shown.hiddenInsetmacOS - Results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.
titleBarOverlayObject Windows Linux (Optional)
This property enables the Window Controls Overlay JavaScript APIs and CSS Environment Variables. This only works if the window is frameless.colorString (Optional)
The CSS color of the Window Controls Overlay when enabled. Default is the system color.symbolColorString Windows (Optional)
The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.heightNumber (Optional)
The height of the title bar and Window Controls Overlay in pixels. Default is system height.
trafficLightPositionPoint macOSxNumberyNumber
Read more about these settings in our Style Guide.
webContentsProperties
devToolsOpenBoolean
If the developer tools are currently open.zoomLevelNumber
Current zoom level.urlString
Current URL loaded in the window.titleString
Document title of the current page.loadingBoolean
If the page is currently loading.canNavigateBackBoolean
If there is a previous page in the history.canNavigateForwardBoolean
If there is a next page in the history.