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

Returns

  • windowId String
  • success Boolean
    If the action was successful.
  • message String
    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

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Focus Window

Focuses on the window.

await window.deskifier.windows.focus({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Blur Window

Unfocuses the window.

await window.deskifier.windows.blur({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Hide Window

Hides the window.

await window.deskifier.windows.hide({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Unmaximize Window

Unmaximizes the window.

await window.deskifier.windows.unmaximize({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Reload Web Contents

Reloads the current web contents.

await window.deskifier.windows.reload({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Toggle Dev Tools

Show/hide the dev tools.

await window.deskifier.windows.toggleDevTools({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.
  • show Boolean (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Goes back a page, if possible.

await window.deskifier.windows.navigateBack({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Goes forward a page, if possible.

await window.deskifier.windows.navigateForward({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Execute JavaScript

Executes JavaScript in the specified window.

await window.deskifier.windows.executeJavaScript({ arguments })

Arguments

  • windowId String (Required)
  • code String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • filePaths Array of Strings
    The paths to the files being dragged. Can be a single file path, or multiple.

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • toWindowId String (Required)
  • message String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • windowIds Array Of Strings

Get Window Properties

Returns an object with the current state of the window.

await window.deskifier.windows.getProperties({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • windowProperties Deskifier.WindowProperties

Get Web Contents Properties

Returns an object with details about the window's web contents object.

await window.deskifier.windows.getWebContentsProperties({ arguments })

Arguments

  • windowId String (Optional)
    Defaults to the current window.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • webContents Deskifier.webContentsProperties

Events

Window Closed

Emitted when a window is closed.

window.deskifier.windows.onClosed((data) => {})

Arguments

  • windowId String

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

  • windowId String

Window Unresponsive

Emitted when a window's webpage becomes unresponsive.

window.deskifier.windows.onUnresponsive((data) => {})

Arguments

  • windowId String

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

  • windowId String

Window Focused

Fires when a browser window is focused.

window.deskifier.windows.onFocused((data) => {})

Arguments

  • windowId String

Window Shown

Fires when a browser window is shown.

window.deskifier.windows.onShown((data) => {})

Arguments

  • windowId String

Window Hidden

Fires when a browser window is hidden.

window.deskifier.windows.onHidden((data) => {})

Arguments

  • windowId String

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

  • windowId String

Window Maximized

Fires when a browser window is maximized.

window.deskifier.windows.onMaximized((data) => {})

Arguments

  • windowId String

Window Unmaximized

Fires when a browser window is unmaximized.

window.deskifier.windows.onUnmaximized((data) => {})

Arguments

  • windowId String

Window Minimized

Fires when a browser window is minimized.

window.deskifier.windows.onMinimized((data) => {})

Arguments

  • windowId String

Window Restored

Fires when a browser window is restored.

window.deskifier.windows.onRestored((data) => {})

Arguments

  • windowId String

Window Resized

Fires when a browser window is resized.

window.deskifier.windows.onResized((data) => {})

Arguments

  • windowId String

Window Moved

Fires when a browser window is moved.

window.deskifier.windows.onMoved((data) => {})

Arguments

  • windowId String

Window Entered Fullscreen

Fires when a browser window enters fullscreen mode.

window.deskifier.windows.onEnteredFullscreen((data) => {})

Arguments

  • windowId String

Window Left Fullscreen

Fires when a browser window leaves fullscreen.

window.deskifier.windows.onLeftFullscreen((data) => {})

Arguments

  • windowId String

Window Entered HTML Fullscreen

Fires when a window enters a full-screen state triggered by HTML API.

window.deskifier.windows.onEnteredHTMLFullscreen((data) => {})

Arguments

  • windowId String

Window Left HTML Fullscreen

Fires when a window leaves a full-screen state triggered by HTML API.

window.deskifier.windows.onLeftHTMLFullscreen((data) => {})

Arguments

  • windowId String

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

  • fromWindowId String
    The window ID that generated the message.
  • toWindowId String
    The window ID that the message was sent to.
  • message String

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

  • paths Array 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

  • width Number
    Width in px. Default is 800.
  • height Number
    Height in px. Default is 600.
  • x Number
    (required if y is used) Window's left offset from screen. Default is to center the window.
  • y Number
    (required if x is used) Window's top offset from screen. Default is to center the window.
  • center Boolean
    Centers the window on screen. Only takes effect when x/y are not provided.
  • minWidth Number
    Window's minimum width. Default is 0.
  • minHeight Number
    Window's minimum height. Default is 0.
  • maxWidth Number
    Window's maximum width. Default is no limit.
  • maxHeight Number
    Window's maximum height. Default is no limit.
  • resizable Boolean
    Controls if the window is resizable.
  • movable Boolean macOS Windows
    Controls if the window can be moved by the user. On Linux does nothing.
  • minimizable Boolean macOS Windows
    Controls if the window can be minimized. On Linux does nothing.
  • maximizable Boolean macOS Windows
    Controls if the window can be maximized. On Linux does nothing.
  • closable Boolean macOS Windows
    Sets if the window can be closed by the user. On Linux does nothing.
  • interceptClose Boolean
    When true, user-initiated close attempts fire the windowCloseAttempt event instead of actually closing the window. Useful for showing a "save before closing?" prompt. Default is false.
  • alwaysOnTop Boolean
    Sets the window to stay on top of other windows.
  • fullscreen Boolean
    Whether the window should show in fullscreen. When explicitly set to false the fullscreen button will be hidden or disabled on macOS. Default is false.
  • fullscreenable Boolean
    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 is true.
  • maximized Boolean
    Whether the window is maximized. Setting to true maximizes the window; setting to false unmaximizes it.
  • skipTaskbar Boolean macOS Windows (Optional)
    Makes the window not show in the taskbar/dock. false by default.
  • kiosk Boolean
    Whether the window is in kiosk mode. Default is false.
  • show Boolean
    When passed as true via updateWindowProperties, shows the window. For full show/hide control, use the dedicated showWindow and hideWindow methods. (Not to be confused with the read-only isVisible.)
  • title String
    Default window title. Default is "Electron". If the HTML tag <title> is defined in the HTML file loaded, this property will be ignored.
  • backgroundColor String
    Sets the window’s background color, in hex (e.g., #FFFFFF).
  • hasShadow Boolean
    Whether window should have a shadow. Default is true.
  • opacity Number macOS Windows
    Sets window transparency, range 0.0 (fully transparent) to 1.0 (fully opaque).
  • ignoreMouseEvents Boolean
    Ignores or allows mouse events. false by default.
  • forwardMouseEvents Boolean macOS Windows
    When ignoreMouseEvents is enabled, allows mouse events to be forwarded to underlying elements, to detect events like mouseEnter and mouseLeave. false by default.
  • visibleOnAllWorkspaces Boolean macOS Linux (Optional)
    Set if the window will show up across all workspaces. Useful for utility applications & floating windows. false by default.
  • trafficLightVisibility Boolean macOS (Optional)
    Set if the traffic lights should be visible.
  • trafficLightPosition Point macOS
    Repositions the traffic light buttons at runtime. Requires the window was created with titleBarStyle: 'hidden' or presetTitleBar: 'Custom Overlay'.
    • x Number
    • y Number
  • titleBarOverlay Object Windows Linux
    Updates the Window Controls Overlay colors and height at runtime. Requires the window was created with titleBarStyle: 'hidden' and the overlay enabled (e.g., via presetTitleBar: 'Overlay').
    • color String
      The CSS color of the overlay.
    • symbolColor String Windows
      The CSS color of the button symbols.
    • height Number
      Height of the title bar in pixels.
  • vibrancy String 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'. Pass null to remove.
  • backgroundMaterial String 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.
  • isMinimized Boolean
    If the window is currently minimized. Read only.
  • isMaximized Boolean
    If the window is currently maximized. Read only.
  • isNormal Boolean
    Whether the window is in normal state (not maximized, not minimized, not in fullscreen mode). Read only.
  • isFocused Boolean
    Whether the window is focused. Read only.
  • isVisible Boolean
    Whether the window is visible to the user in the foreground of the app. Read only.
  • id String
    The window's ID. Read only.

constructorOptions

  • url String (Required)
  • windowId String
    The window ID of the new window. Must be unique. If a value is not given, one will be generated.
  • show Boolean
    Whether to show the window. It's recommended to set this to false, and wait for the ready-to-show event before showing. Default is true.
  • showAfterLoading Boolean
    If true, the window stays hidden until its content finishes loading, then shows automatically. Overrides show internally. Default is false.
  • center Boolean
    Show window in the center of the screen. Default is false.
  • frame Boolean
    Specify false to create a frameless window. Default is true.
  • transparent Boolean
    Makes the window transparent. Default is true. On Windows, does not work unless the window is frameless. Note, this is not the same as the opacity property.
  • presetTitleBar String
    A high-level title bar preset. When set, overrides frame, titleBarStyle, titleBarOverlay, and trafficLightPosition. 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 provide titleBarOverlay to customize button colors on Windows/Linux.
    • Overlay Inset macOS — 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 with trafficLightPosition.
  • titleBarStyle String
    The style of window title bar. Default is default. 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 with titleBarOverlay: true it will activate the Window Controls Overlay (see titleBarOverlay for more information), otherwise no window controls will be shown.
    • hiddenInset macOS - Results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.
  • titleBarOverlay Object Windows Linux (Optional)
    This property enables the Window Controls Overlay JavaScript APIs and CSS Environment Variables. This only works if the window is frameless.
    • color String (Optional)
      The CSS color of the Window Controls Overlay when enabled. Default is the system color.
    • symbolColor String Windows (Optional)
      The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
    • height Number (Optional)
      The height of the title bar and Window Controls Overlay in pixels. Default is system height.
  • trafficLightPosition Point macOS
    • x Number
    • y Number

Read more about these settings in our Style Guide.

webContentsProperties

  • devToolsOpen Boolean
    If the developer tools are currently open.
  • zoomLevel Number
    Current zoom level.
  • url String
    Current URL loaded in the window.
  • title String
    Document title of the current page.
  • loading Boolean
    If the page is currently loading.
  • canNavigateBack Boolean
    If there is a previous page in the history.
  • canNavigateForward Boolean
    If there is a next page in the history.