Skip to content

Window API ​

Methods of the window namespace.

window ​

window.blur ​

Hand the foreground to the window below the calling window in the z-order. Fails when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.blur');

window.broadcast ​

Send a message to every window except the caller, delivered as window:message with { sourceWindowId, message }.

ParameterTypeRequiredDescription
messageanyYesThe message, delivered as message of the event. Passing null is treated as omitted.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.broadcast', { message: { type: 'themeChanged', theme: 'dark' } });

window.cancelClose ​

Keep the calling popup open after it received window:beforeClose; ignored when no close is pending. Fails with NOT_FOUND when the caller is not a popup.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.cancelClose');

window.center ​

Center the calling window on the work area of its monitor, keeping its size. Fails in panel mode and when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.center');

window.clearClickThroughExcludeRegions ​

Remove a popup's click-through exclude rectangles. Targets as window.setClickThrough does.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling window.

Returns

FieldTypeDescription
windowIdstringId of the popup.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// popup-scoped; omit windowId only when calling from the popup itself
await fb2k.invoke('window.clearClickThroughExcludeRegions', { windowId: 'popup-1' });

window.clearDragRegions ​

Remove the calling window's drag rectangles. Fails in panel mode, and with NOT_FOUND when the caller is neither the main window nor a popup.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.clearDragRegions');

window.clearNoDragRegions ​

Remove the calling window's no-drag rectangles. Fails in panel mode, and with NOT_FOUND when the caller is neither the main window nor a popup.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.clearNoDragRegions');

window.close ​

Close the calling window as the system close command does. Succeeds with no operation when there is no window. Fails in panel mode.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.close');

window.closeAllPopups ​

Close every popup as their close buttons do.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.closeAllPopups');

window.closePopup ​

Close a popup as its close button does, so a popup created with beforeClose first gets window:beforeClose. main fails with INVALID_PARAMS, an id no popup has with NOT_FOUND.

ParameterTypeRequiredDescription
windowIdstringYesId of the popup to close. Must not be empty.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// windowId is required here; there is no fallback to the calling window
await fb2k.invoke('window.closePopup', { windowId: 'popup-1' });

window.confirmClose ​

Let the calling popup close after it received window:beforeClose; ignored when no close is pending. Fails with NOT_FOUND when the caller is not a popup.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.confirmClose');

window.createPopup ​

Open a popup window with its own WebView and bridge; at most 8 popups can be open. Works from a DUI/CUI panel too. Fails with OPERATION_FAILED when 8 popups are already open or the window cannot be created.

ParameterTypeRequiredDescription
urlstringNoPage to load. An http://, https://, file:/// or data: URL is loaded as it is; a path containing .html is loaded from the theme (or the development server); anything else, including empty, loads the theme's index.html with this value as the route query parameter. Every URL except data: gets a windowId query parameter. A page loaded from an http:// or https:// URL can use the bridge only when the calling page already trusts that origin; any other absolute URL loads a page that cannot. Such a page still shows, but its calls fail with ORIGIN_DENIED and no event reaches it. Default: "".
titlestringNoWindow title. Default: "".
xnumberNoLeft edge in screen coordinates; omitted, Windows places the window. Fractions are dropped.
ynumberNoTop edge in screen coordinates; omitted, Windows places the window. Fractions are dropped.
widthnumberNoWidth in physical pixels; fractions are dropped. Default: 400.
heightnumberNoHeight in physical pixels; fractions are dropped. Default: 300.
minWidthnumberNoMinimum width for resizing, in physical pixels. Default: 200.
minHeightnumberNoMinimum height for resizing, in physical pixels. Default: 150.
maxWidthnumberNoMaximum width for resizing, in physical pixels; 0 means no bound. Default: 0.
maxHeightnumberNoMaximum height for resizing, in physical pixels; 0 means no bound. Default: 0.
resizablebooleanNoWhether the user can resize the popup. Default: true.
framebooleanNoWhether to draw the native frame and caption; false creates a borderless popup. Default: true.
transparentbooleanNoWhether the background is transparent. Default: false.
alwaysOnTopbooleanNoKeep the popup above every other window. To keep it above the main window only, use the standard preset or behavior.owner: "main" instead. Default: false.
showInTaskbarbooleanNoWhether the popup shows on the taskbar and in Alt+Tab; omitted, the preset decides.
clickThroughbooleanNoLet mouse input pass through the popup. Default: false.
beforeClosebooleanNoSend window:beforeClose and wait for window.confirmClose or window.cancelClose before closing. Default: false.
profilestringNoBehavior preset: standard, miniPlayer or desktopLyrics, case-insensitive, with - or _ allowed (mini-player); an unknown value is standard. Omitted, no preset.
behaviorRecord<string, any>NoBehavior overrides on top of the preset, keyed like resolvedBehavior of window.getPopupBehavior.
backdropPolicyRecord<string, any>NoBackdrop policy overrides on top of the preset, keyed like resolvedBackdropPolicy of window.getBackdropPolicy.

Returns

FieldTypeDescription
windowIdstringId of the new popup.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('window.createPopup', {
    url: 'popup.html',
    width: 480,
    height: 320,
    title: 'Now Playing',
});
if (res.success === false) throw new Error(res.error);
const { windowId } = res;

window.enterFullscreen ​

Enter fullscreen. A window that is already fullscreen fails with OPERATION_FAILED. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
isFullscreenbooleanAlways true.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.enterFullscreen');

window.exitFullscreen ​

Leave fullscreen and restore the state the window had before. A window that is not fullscreen fails with OPERATION_FAILED. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
isFullscreenbooleanAlways false.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.exitFullscreen');

window.flash ​

Flash the calling window's caption and taskbar button to draw attention, or stop flashing. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
enabledbooleanNotrue to flash, false to stop. Default: true.
countintegerNoHow many times to flash. Default: 3.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// omit count and enabled to start flashing 3 times
await fb2k.invoke('window.flash');

window.flashTaskbar ​

Flash the calling window's taskbar button and caption a number of times. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
countintegerNoHow many times to flash. Default: 3.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// omit count to flash 3 times
await fb2k.invoke('window.flashTaskbar');

window.focus ​

Bring a window to the foreground, restoring it first when minimized and showing it when hidden. An explicit id targets exactly that window; omission targets the caller's top-level window, including the host of a panel. Fails with NOT_FOUND when the target no longer exists. Supersedes older popup focus-restoration work without changing the popup's no-activate policy. Success means the request was made; Windows may refuse to grant the foreground.

ParameterTypeRequiredDescription
windowIdstringNomain or a popup id. Omitted or empty, focus the caller's top-level window, including the foobar2000 host in DUI/CUI panel mode. An unknown explicit id fails with NOT_FOUND.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// omit windowId to focus the calling window
await fb2k.invoke('window.focus');

window.getAllWindows ​

List the main window and every popup with their policies, capabilities and rectangles.

This method takes no parameters.

Returns

FieldTypeDescription
itemsWindowInfo[]The main window first, then the popups.
items[].windowIdstringmain or the popup id.
items[].isMainbooleanWhether this is the main window.
items[].titlestringWindow title.
items[].urlstringPopups only: initial URL specified when the popup was created.
items[].profile"legacy" | "standard" | "miniPlayer" | "desktopLyrics"Popups only: the behavior preset; legacy when the popup was created without one.
items[].behaviorRecord<string, any>Popups only: the behavior overrides set on the popup.
items[].resolvedBehaviorWindowPopupBehaviorStatePopups only: the behavior in effect.
items[].resolvedBehavior.showInTaskbarbooleanWhether the popup shows on the taskbar.
items[].resolvedBehavior.showInAltTabbooleanWhether the popup shows in Alt+Tab.
items[].resolvedBehavior.keepVisibleOnShowDesktopbooleanWhether the popup stays visible when the desktop is shown.
items[].resolvedBehavior.allowMinimizebooleanWhether the popup can be minimized.
items[].resolvedBehavior.owner"none" | "main"main keeps the popup above the main window and minimizes it with the main window; none makes it independent.
items[].resolvedBehavior.noActivatebooleanWhether showing or clicking the popup leaves the focus where it was.
items[].backdropPolicyRecord<string, any>The backdrop policy overrides set on the window.
items[].resolvedBackdropPolicyWindowBackdropPolicyStateThe backdrop policy in effect.
items[].resolvedBackdropPolicy.activeEffect"inherit" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is active; inherit follows the foobar2000 preferences.
items[].resolvedBackdropPolicy.inactiveEffect"inherit" | "system" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is inactive: inherit keeps the active one and lets Windows dim it, system hands the frame back to the platform backdrop.
items[].resolvedBackdropPolicy.darkModebooleanWhether the backdrop uses its dark variant.
items[].resolvedBackdropPolicy.reapplyOnActivatebooleanWhether the backdrop is written again on every activation.
items[].capabilitiesWindowObservationCapabilitiesFeatures the window supports.
items[].capabilities.supportsBackdropPolicybooleanWhether window.setBackdropPolicy applies.
items[].capabilities.supportsFramelessbooleanWhether window.setFrameless applies.
items[].capabilities.supportsCornerPreferencebooleanWhether window.setCornerPreference applies.
items[].capabilities.supportsPopupBehaviorbooleanWhether window.setPopupBehavior applies.
items[].capabilities.supportsMicaAltbooleanWhether the Mica Alt backdrop can be drawn.
items[].capabilities.supportsFullscreenbooleanWhether the window can go fullscreen.
items[].capabilities.supportsOwnerPolicybooleanWhether behavior.owner applies.
items[].capabilities.supportsNoActivatebooleanWhether behavior.noActivate applies.
items[].capabilities.supportsBeforeClosebooleanWhether beforeClose applies.
items[].boundsWindowBoundsThe window rectangle.
items[].bounds.xintegerLeft edge.
items[].bounds.yintegerTop edge.
items[].bounds.widthintegerWidth.
items[].bounds.heightintegerHeight.
items[].shellanyDiagnostic snapshot of the window shell (lifecycle and startup state); its shape can change between versions.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getAllWindows');

window.getBackdropPolicy ​

Report a window's backdrop policy: the overrides set on it and the policy in effect.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
windowIdstringId of the window the call acted on.
backdropPolicyRecord<string, any>The backdrop policy overrides set on the window.
resolvedBackdropPolicyWindowBackdropPolicyStateThe backdrop policy in effect.
resolvedBackdropPolicy.activeEffect"inherit" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is active; inherit follows the foobar2000 preferences.
resolvedBackdropPolicy.inactiveEffect"inherit" | "system" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is inactive: inherit keeps the active one and lets Windows dim it, system hands the frame back to the platform backdrop.
resolvedBackdropPolicy.darkModebooleanWhether the backdrop uses its dark variant.
resolvedBackdropPolicy.reapplyOnActivatebooleanWhether the backdrop is written again on every activation.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

resolvedBackdropPolicy is the effective policy after profile defaults are applied.

  • activeEffect values: inherit | none | mica | mica-alt | acrylic (the WindowActiveBackdropEffect type)
  • inactiveEffect values: inherit | system | none | mica | mica-alt | acrylic (the WindowInactiveBackdropEffect type). inherit is the host default: the unfocused window keeps the resolved activeEffect and DWM applies its own inactive dimming. system hands the unfocused frame back to the platform backdrop. A string outside the table is not rejected: it is echoed in backdropPolicy, but resolvedBackdropPolicy keeps its previous effect.
js
// omit windowId to read the calling window
const res = await fb2k.invoke('window.getBackdropPolicy');
if (res.success === false) throw new Error(res.error);
const { resolvedBackdropPolicy } = res;

window.getBounds ​

Report the calling window's rectangle in screen coordinates, in physical pixels, frame included. While the window is minimized this is where Windows parks it, not the geometry it restores to. The rectangle is zero when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
xintegerLeft edge in screen coordinates.
yintegerTop edge in screen coordinates.
widthintegerWidth in physical pixels, frame included.
heightintegerHeight in physical pixels, frame included.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getBounds');

window.getCaptionButtonsWidth ​

Report the width of the main window's caption buttons (minimize, maximize, close) in physical pixels at its DPI. Main window only; without one the call reports 138 and 46 rather than failing.

This method takes no parameters.

Returns

FieldTypeDescription
widthintegerWidth of the three buttons together.
buttonWidthintegerWidth of one button.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels and track the main window's DPI. When no main window exists the call returns the DIP-baseline defaults (width: 138, buttonWidth: 46) rather than an error, so callers cannot distinguish "no window" from a genuine 100%-scale measurement.

js
const result = await fb2k.invoke('window.getCaptionButtonsWidth');

window.getCornerPreference ​

Report the main window's corner rounding as last set; default when there is no main window.

This method takes no parameters.

Returns

FieldTypeDescription
modestringThe corner rounding as last set.
preferencestringSame value as mode.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

When no main window exists the call returns "default" rather than an error.

js
const result = await fb2k.invoke('window.getCornerPreference');

window.getCurrentWindowId ​

Report the id of the calling window: main, a popup id or a panel's id. A caller that cannot be matched gets main.

This method takes no parameters.

Returns

FieldTypeDescription
windowIdstringId of the calling window.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getCurrentWindowId');

window.getDevServerConfig ​

Report whether pages load from a development server instead of the installed files, and that server's address.

This method takes no parameters.

Returns

FieldTypeDescription
useDevServerbooleanWhether pages load from the development server.
devServerUrlstringAddress of the development server.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getDevServerConfig');

window.getDpiScale ​

Report the DPI of the calling window's device context and its ratio to 96; 96 when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
dpiintegerDPI; 96 is 100 %.
scalenumberdpi / 96.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getDpiScale');

window.getMaxSize ​

Report a window's requested maximum size; 0 means no bound.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
widthintegerMaximum width in physical pixels at the window's current DPI; 0 means no bound.
heightintegerMaximum height in physical pixels at the window's current DPI; 0 means no bound.
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels; the host stores constraints in DIPs and converts using the target window's DPI. 0 means "no upper bound" and survives the conversion exactly.

The returned values are the requested constraints, not the currently effective window size. A physical → DIP → physical round-trip is quantized to whole DIPs, so at non-100% scaling get may differ from the value passed to set by up to 1px per axis (for example, 202px at 125% reads back as 203px). Treat the getters as reporting the constraint you set to within ±1px rather than byte-for-byte. 0 is exempt.

js
const result = await fb2k.invoke('window.getMaxSize');

window.getMinSize ​

Report a window's requested minimum size, which is the value last set rather than the effective window size.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
widthintegerMinimum width in physical pixels at the window's current DPI.
heightintegerMinimum height in physical pixels at the window's current DPI.
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels; the host stores constraints in DIPs and converts using the target window's DPI.

The returned values are the requested constraints, not the currently effective window size. A physical → DIP → physical round-trip is quantized to whole DIPs, so at non-100% scaling get may differ from the value passed to set by up to 1px per axis (for example, 202px at 125% reads back as 203px). Treat the getters as reporting the constraint you set to within ±1px rather than byte-for-byte.

js
const result = await fb2k.invoke('window.getMinSize');

window.getMode ​

Report the calling page's hosting mode and window id. The main window and popups report standalone with panelMode: false, including popups opened from a panel. A registered window with an id reports the same id as window.getCurrentWindowId. Pages that adapt to panel mode read it on startup; DUI/CUI panels also announce the same fields with panel:initialized.

This method takes no parameters.

Returns

FieldTypeDescription
mode"standalone" | "dui" | "cui" | "panel" | "unknown"standalone, dui or cui; panel when the page is in a panel that could not be told apart, unknown for a panel of an unrecognized kind.
panelModebooleanWhether the page is in a DUI or CUI panel; false for the main window and popups.
windowIdstringId of the calling window: main for the main window, the popup's actual id, or the panel's id. A panel without an id reports panel; an unmatched caller reports main.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getMode');

window.getPopupBehavior ​

Report a popup's behavior preset, the overrides set on it and the behavior in effect. Popups only: main fails with NOT_SUPPORTED; without windowId the calling popup is used, and a caller that is not a popup fails with NOT_FOUND.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling popup.

Returns

FieldTypeDescription
windowIdstringId of the popup.
profile"legacy" | "standard" | "miniPlayer" | "desktopLyrics"The behavior preset; legacy when the popup was created without one.
behaviorRecord<string, any>The behavior overrides set on the popup.
resolvedBehaviorWindowPopupBehaviorStateThe behavior in effect.
resolvedBehavior.showInTaskbarbooleanWhether the popup shows on the taskbar.
resolvedBehavior.showInAltTabbooleanWhether the popup shows in Alt+Tab.
resolvedBehavior.keepVisibleOnShowDesktopbooleanWhether the popup stays visible when the desktop is shown.
resolvedBehavior.allowMinimizebooleanWhether the popup can be minimized.
resolvedBehavior.owner"none" | "main"main keeps the popup above the main window and minimizes it with the main window; none makes it independent.
resolvedBehavior.noActivatebooleanWhether showing or clicking the popup leaves the focus where it was.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const info = await fb2k.invoke('window.getPopupBehavior', { windowId: 'popup-1' });

window.getState ​

Report the calling window's state flags and rectangle. Every flag is sent twice, bare and is-prefixed. When there is no window every flag is false and the rectangle is zero.

This method takes no parameters.

Returns

FieldTypeDescription
maximizedbooleanWhether the window is maximized.
minimizedbooleanWhether the window is minimized.
fullscreenbooleanWhether the window is fullscreen.
alwaysOnTopbooleanWhether the window is kept above other windows.
focusedbooleanWhether the window is the foreground window.
isMaximizedbooleanSame value as maximized.
isMinimizedbooleanSame value as minimized.
isFullscreenbooleanSame value as fullscreen.
isAlwaysOnTopbooleanSame value as alwaysOnTop.
isFocusedbooleanSame value as focused.
widthintegerWidth in physical pixels, frame included.
heightintegerHeight in physical pixels, frame included.
xintegerLeft edge in screen coordinates.
yintegerTop edge in screen coordinates.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getState');

window.getTitle ​

Report the calling window's title, up to 255 characters; empty when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
titlestringThe window title.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getTitle');

window.getTitlebarHeight ​

Report the title bar height of the calling window, the main window or a popup, in physical pixels. A caller that is neither gets the default, 32.

This method takes no parameters.

Returns

FieldTypeDescription
heightintegerTitle bar height in physical pixels.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getTitlebarHeight');

window.getTitlebarInfo ​

Report the main window's title bar height, caption button widths and maximized state together, in physical pixels. Main window only; without one the call reports 32, 138, 46 and false.

This method takes no parameters.

Returns

FieldTypeDescription
heightintegerTitle bar height in physical pixels.
captionButtonsWidthintegerWidth of the three caption buttons together.
captionButtonWidthintegerWidth of one caption button.
isMaximizedbooleanWhether the main window is maximized.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels and track the main window's DPI. When no main window exists the call returns the DIP-baseline defaults (height: 32, captionButtonsWidth: 138, captionButtonWidth: 46) rather than an error; those fallbacks are unscaled, so on non-100% displays they differ in unit from the normal path.

js
const result = await fb2k.invoke('window.getTitlebarInfo');

window.getZoom ​

Report the zoom factor of the calling window's WebView, the window's DPI and the Windows text size; the page's devicePixelRatio is dpiScale * textScaleFactor * zoom. Without a WebView of its own the call reports zoom 1 and leaves out dpi and dpiScale.

This method takes no parameters.

Returns

FieldTypeDescription
zoomnumberThe zoom factor; 1 is 100 %.
dpiintegerThe window's DPI; left out without a WebView.
dpiScalenumberdpi / 96; left out without a WebView.
textScaleFactornumberThe Windows text size as a factor, 1 to 2.25, which the host applies to its WebViews together with the DPI; 1 when Windows does not report one.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.getZoom');

window.hasSavedBounds ​

Report whether an earlier session saved the main window's position, which a page can use to decide whether to apply a default size on first launch.

This method takes no parameters.

Returns

FieldTypeDescription
hasSavedBoundsbooleanWhether a position from an earlier session is saved.
descriptionstringAn English sentence restating hasSavedBounds, for logs.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.hasSavedBounds');

window.isAlwaysOnTop ​

Report whether the calling window is kept above other windows; false when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
enabledbooleanWhether the window is kept above other windows.
isAlwaysOnTopbooleanSame value as enabled.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.isAlwaysOnTop');

window.isClickThrough ​

Report whether mouse input passes through a popup. Targets as window.setClickThrough does.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling window.

Returns

FieldTypeDescription
clickThroughbooleanWhether mouse input passes through.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('window.isClickThrough', { windowId: 'popup-1' });
if (res.success === false) throw new Error(res.error);
const { clickThrough } = res;

window.isFullscreen ​

Report whether a window is fullscreen.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
fullscreenbooleanWhether the window is fullscreen.
isFullscreenbooleanSame value as fullscreen.
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// omit windowId to query the calling window
const res = await fb2k.invoke('window.isFullscreen');
if (res.success === false) throw new Error(res.error);
const { isFullscreen } = res;

window.isMaximized ​

Report whether the calling window is maximized; false when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
maximizedbooleanWhether the window is maximized.
isMaximizedbooleanSame value as maximized.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.isMaximized');

window.isMinimized ​

Report whether the calling window is minimized; false when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
minimizedbooleanWhether the window is minimized.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.isMinimized');

window.isResizable ​

Report whether the user can resize a window by its frame.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
resizablebooleanWhether the user can resize the window by its frame.
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Every window shell — including fully borderless popups — supports changing this at runtime via window.setResizable.

js
const result = await fb2k.invoke('window.isResizable');

window.maximize ​

Maximize the calling window with the system animation, leaving fullscreen first when it is fullscreen. The request is posted. Fails in panel mode and when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.maximize');

window.minimize ​

Minimize the calling window with the system animation. The request is posted, so the window changes state after the call returns. Fails in panel mode and when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.minimize');

window.refreshWebView ​

Redraw the calling window's WebView, which clears rendering left behind by a backdrop change. Fails with NOT_FOUND when the calling window has no WebView of its own, as with a DUI/CUI panel.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.refreshWebView');

window.reload ​

Reload the calling window's page. Fails with NOT_FOUND when the calling window has no WebView of its own, as with a DUI/CUI panel.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.reload');

window.resetZoom ​

Set the zoom factor of the calling window's WebView back to 1; as with window.setZoom, the default zoom in the preferences no longer applies to it afterwards. Fails with NOT_FOUND when the calling window has no WebView of its own, and with OPERATION_FAILED when WebView2 refuses the factor.

This method takes no parameters.

Returns

FieldTypeDescription
zoomnumberAlways 1.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.resetZoom');

window.restore ​

Restore the calling window from minimized or maximized with the system animation. A fullscreen window leaves fullscreen instead and returns to the state it had before. Fails in panel mode and when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.restore');

window.sendMessage ​

Send a message to one window, delivered as window:message with { sourceWindowId, message }. Fails with NOT_FOUND when no window has that id.

ParameterTypeRequiredDescription
targetWindowIdstringYesId of the receiving window. Must not be empty.
messageanyYesThe message, delivered as message of the event. Passing null is treated as omitted.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.sendMessage', {
    targetWindowId: 'popup-1',
    message: { type: 'seek', position: 42 },
});

window.setAcrylic ​

Enable or disable the Acrylic backdrop material on a window. If the effect cannot be applied immediately, the configuration is still saved; the call fails with OPERATION_FAILED and includes result fields in the error response. Not supported in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNotrue shows acrylic; false removes the backdrop set through setMica or setAcrylic. Default: true.
darkModebooleanNoDark (true) or light (false) backdrop; omitted, unchanged.

Returns

FieldTypeDescription
enabledbooleanEcho of enabled.
darkModebooleanEcho of darkMode; present only when specified in the request.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

success reports whether the backdrop was actually applied, so it can be false even for a valid window when the platform refuses the effect.

js
await fb2k.invoke('window.setAcrylic', { enabled: true, darkMode: true });

window.setAlwaysOnTop ​

Keep the calling window above other windows, or stop doing so. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
enabledbooleanNoWhether to keep the window above other windows. Default: true.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setAlwaysOnTop', { enabled: true });

window.setBackdropPolicy ​

Merge per-field overrides into a window's backdrop policy; passing null removes that override. Overrides are saved even if the window cannot apply them immediately (such as while hidden at startup); the call then fails with OPERATION_FAILED.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
backdropPolicyRecord<string, any>YesOverrides keyed like resolvedBackdropPolicy, merged into the current ones; a null value removes that override. Other keys are stored and echoed but have no effect, and an effect name outside the allowed values leaves the effect in use unchanged.

Returns

FieldTypeDescription
windowIdstringId of the window the call acted on.
backdropPolicyRecord<string, any>The backdrop policy overrides after the merge.
resolvedBackdropPolicyWindowBackdropPolicyStateThe backdrop policy in effect.
resolvedBackdropPolicy.activeEffect"inherit" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is active; inherit follows the foobar2000 preferences.
resolvedBackdropPolicy.inactiveEffect"inherit" | "system" | "none" | "mica" | "mica-alt" | "acrylic"Backdrop while the window is inactive: inherit keeps the active one and lets Windows dim it, system hands the frame back to the platform backdrop.
resolvedBackdropPolicy.darkModebooleanWhether the backdrop uses its dark variant.
resolvedBackdropPolicy.reapplyOnActivatebooleanWhether the backdrop is written again on every activation.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Value tables match window.getBackdropPolicy:

  • activeEffect values: inherit | none | mica | mica-alt | acrylic (the WindowActiveBackdropEffect type)
  • inactiveEffect values: inherit | system | none | mica | mica-alt | acrylic (the WindowInactiveBackdropEffect type). inherit is the host default: the unfocused window keeps the resolved activeEffect and DWM applies its own inactive dimming. system hands the unfocused frame back to the platform backdrop. A string outside the table is not rejected: it is echoed in backdropPolicy, but resolvedBackdropPolicy keeps its previous effect.
js
await fb2k.invoke('window.setBackdropPolicy', {
    backdropPolicy: { activeEffect: 'acrylic', darkMode: true },
});

// Keep the resolved activeEffect while unfocused; DWM dims the frame itself
await fb2k.invoke('window.setBackdropPolicy', {
    backdropPolicy: { activeEffect: 'mica', inactiveEffect: 'inherit' },
});

window.setBackgroundTransparency ​

Set the window WebView background to transparent (revealing backdrop material effects) or opaque. Not supported in panel mode. Fails with OPERATION_FAILED (carrying result fields when the window has a WebView) if neither the window nor the WebView accepted the change.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
transparentbooleanNotrue for a transparent background, false for an opaque one. Default: true.

Returns

FieldTypeDescription
transparentbooleanEcho of transparent.
descriptionstringAn English sentence describing the new state, for logs.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setBackgroundTransparency', { transparent: true });

window.setBlur ​

Enable or disable the blur-behind effect on a window. If the effect cannot be applied immediately, the configuration is still saved; the call fails with OPERATION_FAILED and includes enabled in the error response. Not supported in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNoWhether to blur what is behind the window. Default: true.

Returns

FieldTypeDescription
enabledbooleanEcho of enabled.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setBlur', { enabled: true });

window.setBounds ​

Move or resize the calling window in one call; omitted keys keep their current value and fractions are dropped. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
xnumberNoNew left edge in screen coordinates.
ynumberNoNew top edge in screen coordinates.
widthnumberNoNew width in physical pixels, frame included.
heightnumberNoNew height in physical pixels, frame included.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setBounds', { x: 100, y: 100, width: 480, height: 320 });

window.setClickThrough ​

Let mouse input pass through a popup to the windows below, except over the rectangles set with window.setClickThroughExcludeRegions. Popups only: without windowId the calling window is used, and a window that is not a popup fails with NOT_FOUND.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling window.
enabledbooleanNoWhether mouse input passes through. Default: true.

Returns

FieldTypeDescription
clickThroughbooleanWhether mouse input passes through now.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setClickThrough', { enabled: true });

window.setClickThroughExcludeRegions ​

Set the rectangles of a popup that keep taking mouse input while it lets input pass through, replacing the earlier ones. Rectangles are CSS pixels of the popup's page, scaled by its devicePixelRatio: the popup's DPI, the Windows text size and the page zoom. Set them again when devicePixelRatio changes. Rectangles without a positive width and height are skipped, and at most 32 are kept. Targets as window.setClickThrough does.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling window.
regionsWindowRegion[]NoThe rectangles; omitted, none.
regions[].xnumberNoLeft edge. Default: 0.
regions[].ynumberNoTop edge. Default: 0.
regions[].widthnumberNoWidth. Default: 0.
regions[].heightnumberNoHeight. Default: 0.

Returns

FieldTypeDescription
windowIdstringId of the popup.
countintegerHow many rectangles were kept.
dpiScalenumberThe popup's DPI divided by 96.
scalenumberScale applied to the rectangles, the devicePixelRatio of the popup's page.
warningstringregions truncated to 32 when more than 32 rectangles were given.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setClickThroughExcludeRegions', {
    regions: [{ x: 12, y: 12, width: 160, height: 40 }],
});

window.setCornerPreference ​

Set the main window's Windows 11 corner rounding. Main window only, whichever window calls; popups manage their corners themselves. Fails in panel mode and when there is no main window.

ParameterTypeRequiredDescription
modestringNodefault or round rounds the corners, small rounds them slightly and none keeps them square. Any other value rounds them and is reported back as given. Default: "default".

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

"default" maps to rounded corners, because a borderless window has no standard non-client frame for the system default to apply to.

js
await fb2k.invoke('window.setCornerPreference', { mode: 'round' });

window.setDarkMode ​

Switch a window's backdrop between dark and light themes. If the change cannot be applied immediately, the configuration is still saved; the call fails with OPERATION_FAILED and includes enabled in the error response. Not supported in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNotrue for the dark variant, false for the light one. Default: true.

Returns

FieldTypeDescription
enabledbooleanEcho of enabled.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setDarkMode', { enabled: true });

window.setDevServerConfig ​

Change the development server settings; omitted keys keep their value. They are used the next time a page loads. The response reports both settings as stored.

ParameterTypeRequiredDescription
useDevServerbooleanNoWhether pages load from the development server.
devServerUrlstringNoAddress of the development server, such as http://localhost:5173; stored as given.

Returns

FieldTypeDescription
useDevServerbooleanWhether pages load from the development server, as stored.
devServerUrlstringAddress of the development server, as stored.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setDevServerConfig', {
    useDevServer: true,
    devServerUrl: 'http://localhost:5173',
});

window.setDragRegions ​

Set draggable rectangles for the calling window (main window or popup), replacing earlier ones. Rectangles use page CSS pixels and are scaled by devicePixelRatio (window DPI, text scaling, and zoom). Update these rectangles whenever devicePixelRatio changes. Rectangles without positive width and height are ignored. Fails in panel mode, or with NOT_FOUND if the caller is neither the main window nor a popup.

ParameterTypeRequiredDescription
regionsWindowRegion[]NoThe drag rectangles; omitted, none.
regions[].xnumberNoLeft edge. Default: 0.
regions[].ynumberNoTop edge. Default: 0.
regions[].widthnumberNoWidth. Default: 0.
regions[].heightnumberNoHeight. Default: 0.

Returns

FieldTypeDescription
countintegerHow many rectangles were kept.
dpiScalenumberThe window's DPI divided by 96.
scalenumberScale applied to the rectangles, the page's devicePixelRatio.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setDragRegions', {
    regions: [{ x: 0, y: 0, width: 800, height: 32 }],
});

window.setFrameless ​

Remove or restore the native frame and caption of a window. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
framelessbooleanNotrue removes the frame, false restores it. Default: true.

Returns

FieldTypeDescription
framelessbooleanWhether the window is frameless now.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setFrameless', { frameless: true });

window.setFullscreen ​

Enter or leave fullscreen. Setting the state the window already has succeeds. Leaving fullscreen restores the rectangle, the maximized state and the always-on-top state the window had before. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNotrue to enter fullscreen, false to leave it. Default: true.

Returns

FieldTypeDescription
fullscreenbooleanWhether the window is fullscreen now.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setFullscreen', { enabled: true });

window.setMaximizeButtonRegion ​

Register the custom maximize button rectangle on the main window to enable Windows 11 Snap layouts. The rectangle uses page CSS pixels and scales with devicePixelRatio. It replaces any previous rectangle; omitting region or passing non-positive dimensions clears the registration. When the window is frameless, resizable, and not fullscreen, the host reports this area as the system maximize button while forwarding mouse events to the page (preserving CSS hover styles and click handlers). On Windows 10 or in other states, the area behaves as normal page content. Re-register whenever button layout moves or devicePixelRatio changes. Page reload or navigation clears this registration. Main window only: fails with NOT_SUPPORTED from popups, in panel mode, or with NOT_FOUND without a window.

ParameterTypeRequiredDescription
regionWindowRegionNoCustom maximize button bounding box in CSS pixels; omitted or zero-sized to clear.
region.xnumberNoLeft edge. Default: 0.
region.ynumberNoTop edge. Default: 0.
region.widthnumberNoWidth. Default: 0.
region.heightnumberNoHeight. Default: 0.

Returns

FieldTypeDescription
hasRegionbooleanWhether an active maximize button rectangle is registered.
snapLayoutsbooleanWhether the system provides Windows 11 Snap layouts. When false, the host never reports this area as the maximize button. When true, avoid using HTML title tooltips on the button as they obstruct the Snap flyout; use aria-label instead.
scalenumberScale applied to the rectangle, the page's devicePixelRatio: the window's DPI divided by 96, times the Windows text size and the page zoom.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

In Windows 11, the operating system triggers Snap layouts only over the native maximize button. For custom, page-drawn maximize buttons, the host responds to hit-testing with the supplied rectangle as the system maximize button. Mouse events are forwarded to the WebView so that :hover, :active, and click behaviors remain intact, while maximizing is handled by the page's click handler. The rectangle should remain synchronized with the DOM: register it after initial layout and recalculate on window resize, maximize/restore, or DPI/zoom changes. When snapLayouts is true, remove the button's HTML title attribute and use aria-label instead to prevent tooltips from obscuring the Snap flyout.

js
const button = document.getElementById('maximize');
const report = () => {
    if (!button) return;
    const r = button.getBoundingClientRect();
    void fb2k.invoke('window.setMaximizeButtonRegion', {
        region: { x: r.left, y: r.top, width: r.width, height: r.height },
    });
};
if (button) new ResizeObserver(report).observe(button);
window.addEventListener('resize', report);

window.setMaxSize ​

Set a window's maximum size; 0 removes the bound and fractions are dropped. The host keeps it in DIPs of the target window, so it reads back within 1 px (0 exactly). A window larger than the new maximum shrinks at once, unless it is maximized, fullscreen or minimized. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
widthnumberNoMaximum width in physical pixels; 0 removes the bound. Default: 0.
heightnumberNoMaximum height in physical pixels; 0 removes the bound. Default: 0.

Returns

FieldTypeDescription
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels, converted to the host's DIP storage using the target window's DPI; 0 (or negative) clears the bound. Applying a constraint re-validates the current window size immediately, so a window already larger than the new maximum is shrunk rather than waiting for the next user resize.

js
await fb2k.invoke('window.setMaxSize', { width: 1920, height: 1080 });

window.setMica ​

Enable or disable the Mica backdrop material on a window. If the effect cannot be applied immediately (such as while the window is hidden at startup), the configuration is still saved; the call fails with OPERATION_FAILED and includes result fields in the error response. Not supported in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNotrue shows Mica; false removes the backdrop set through setMica or setAcrylic. Default: true.
variantstringNomica-alt for the tabbed variant; any other value is mica. Default: "mica".
darkModebooleanNoDark (true) or light (false) backdrop; omitted, unchanged.

Returns

FieldTypeDescription
enabledbooleanEcho of enabled.
variantstringThe variant used, mica or mica-alt.
darkModebooleanEcho of darkMode; present only when specified in the request.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Only mica-alt selects the alternate variant; every other value — including an unrecognized one — is normalized to mica rather than rejected. The returned variant echoes that normalized request, not the effect that ended up on screen: popups do not support Mica Alt and are downgraded, so variant: "mica-alt" can come back for a window that received a different backdrop. success reports whether the backdrop was actually applied and can be false for a valid window when the platform refuses the effect.

js
await fb2k.invoke('window.setMica', { enabled: true, variant: 'mica-alt' });

window.setMicaEffect ​

Same as window.setMica.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
enabledbooleanNotrue shows Mica; false removes the backdrop set through setMica or setAcrylic. Default: true.
variantstringNomica-alt for the tabbed variant; any other value is mica. Default: "mica".
darkModebooleanNoDark (true) or light (false) backdrop; omitted, unchanged.

Returns

FieldTypeDescription
enabledbooleanEcho of enabled.
variantstringThe variant used, mica or mica-alt.
darkModebooleanEcho of darkMode; present only when specified in the request.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setMicaEffect', { enabled: true });

window.setMinSize ​

Set a window's minimum size; fractions are dropped. The host keeps it in DIPs of the target window, so it reads back within 1 px. A window smaller than the new minimum grows at once, unless it is maximized, fullscreen or minimized (a minimized window grows when restored). Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
widthnumberNoMinimum width in physical pixels; 0 or less lowers it to 1 DIP. Default: 0.
heightnumberNoMinimum height in physical pixels; 0 or less lowers it to 1 DIP. Default: 0.

Returns

FieldTypeDescription
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Values are physical pixels, converted to the host's DIP storage using the target window's DPI, which keeps the constraint stable across DPI changes. Non-positive values normalise to a 1px floor. Applying a constraint re-validates the current window size immediately, so a window already smaller than the new minimum is grown rather than waiting for the next user resize.

js
await fb2k.invoke('window.setMinSize', { width: 480, height: 320 });

window.setNoDragRegions ​

Set non-draggable exclusion rectangles (such as buttons inside a drag area), replacing earlier ones. Rectangles use page CSS pixels and are scaled by devicePixelRatio. Update these rectangles whenever devicePixelRatio changes. Rectangles without positive width and height are ignored. Fails in panel mode, or with NOT_FOUND if the caller is neither the main window nor a popup.

ParameterTypeRequiredDescription
regionsWindowRegion[]NoThe no-drag rectangles; omitted, none.
regions[].xnumberNoLeft edge. Default: 0.
regions[].ynumberNoTop edge. Default: 0.
regions[].widthnumberNoWidth. Default: 0.
regions[].heightnumberNoHeight. Default: 0.

Returns

FieldTypeDescription
countintegerHow many rectangles were kept.
dpiScalenumberThe window's DPI divided by 96.
scalenumberScale applied to the rectangles, the page's devicePixelRatio.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setNoDragRegions', {
    regions: [{ x: 690, y: 0, width: 110, height: 32 }],
});

window.setPopupBehavior ​

Change a popup's behavior preset or its per-field overrides at runtime, then announce the result with window:behaviorChanged. profile and behavior are independent: passing one leaves the other alone. Targets as window.getPopupBehavior does; an unknown preset fails with INVALID_PARAMS.

ParameterTypeRequiredDescription
windowIdstringNoId of the popup; omitted or empty, the calling popup.
profilestringNoNew preset: standard, miniPlayer or desktopLyrics, case-insensitive, with - or _ allowed (mini-player).
behaviorRecord<string, any>NoOverrides merged into the current ones; a null value removes that override.

Returns

FieldTypeDescription
windowIdstringId of the popup.
profile"legacy" | "standard" | "miniPlayer" | "desktopLyrics"The behavior preset.
behaviorRecord<string, any>The behavior overrides after the merge.
resolvedBehaviorWindowPopupBehaviorStateThe behavior in effect.
resolvedBehavior.showInTaskbarbooleanWhether the popup shows on the taskbar.
resolvedBehavior.showInAltTabbooleanWhether the popup shows in Alt+Tab.
resolvedBehavior.keepVisibleOnShowDesktopbooleanWhether the popup stays visible when the desktop is shown.
resolvedBehavior.allowMinimizebooleanWhether the popup can be minimized.
resolvedBehavior.owner"none" | "main"main keeps the popup above the main window and minimizes it with the main window; none makes it independent.
resolvedBehavior.noActivatebooleanWhether showing or clicking the popup leaves the focus where it was.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

resolvedBehavior is the effective policy after the profile defaults and your overrides are merged. profile and behavior are independent: supplying one does not reset the other, and a null value inside behavior erases that override rather than storing null.

Profile matching is case-insensitive and also accepts hyphen and underscore spellings, so miniPlayer, miniplayer, mini-player, and mini_player are equivalent. A preset that was set is reported under its canonical name; a popup created without one reports legacy until a preset is set.

Passing windowId: "main" fails with NOT_SUPPORTED. Omitting windowId requires the caller to itself be a popup, otherwise the call fails with NOT_FOUND.

js
// switch profile only
await fb2k.invoke('window.setPopupBehavior', { profile: 'miniPlayer' });
// field-level override, keeping the current profile
await fb2k.invoke('window.setPopupBehavior', {
    behavior: { showInTaskbar: true, showInAltTab: true }
});
// clear a field, falling back to the profile default
await fb2k.invoke('window.setPopupBehavior', {
    behavior: { showInTaskbar: null }
});

window.setPosition ​

Move the calling window's top-left corner, keeping its size; fractions are dropped. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
xnumberNoNew left edge in screen coordinates. Default: 0.
ynumberNoNew top edge in screen coordinates. Default: 0.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setPosition', { x: 100, y: 100 });

window.setResizable ​

Set whether the user can resize a window by its frame. Setting the value the window already has succeeds. Fails in panel mode, and with OPERATION_FAILED when Windows refuses the new style; that failure carries windowId.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.
resizablebooleanNoWhether the user can resize the window by its frame. Default: true.

Returns

FieldTypeDescription
windowIdstringId of the window the call acted on.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Every window shell supports this at runtime, including fully borderless popups (frame: false plus transparent: true with no backdrop effect): those windows collapse their entire non-client area, so adding a sizing border changes hit-testing without altering appearance. success: false therefore indicates a genuine Win32 failure — the style could not be written, or the frame could not be refreshed — not an unsupported window shape; the requested state is not committed in that case. This method always targets the calling context window or the explicit target named in windowId.

js
await fb2k.invoke('window.setResizable', { resizable: false });

window.setSize ​

Resize the calling window, keeping its position; fractions are dropped. The size stays within the window's minimum and maximum, and the response does not say whether it was held back. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
widthnumberNoNew width in physical pixels, frame included. Default: 800.
heightnumberNoNew height in physical pixels, frame included. Default: 600.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setSize', { width: 1024, height: 640 });

window.setTitle ​

Set the calling window's title, shown in the title bar and on the taskbar. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
titlestringNoThe new title. Default: "foobar2000".

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setTitle', { title: 'Now Playing' });

window.setTitlebarHeight ​

Set the title bar height of the calling window, the main window or a popup; a popup's height leaves the main window alone. The height must be 24 to 100, otherwise the call fails with INVALID_PARAMS. Fails in panel mode, and with NOT_FOUND when the caller is neither the main window nor a popup.

ParameterTypeRequiredDescription
heightnumberNoTitle bar height in physical pixels, 24 to 100; fractions are dropped. Default: 32.

Returns

FieldTypeDescription
heightintegerThe height that was set.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setTitlebarHeight', { height: 40 });

window.setZoom ​

Set the zoom factor of the calling window's WebView. From then on, for the rest of the session, the default zoom in the preferences no longer applies to this WebView. Fails with NOT_FOUND when the calling window has no WebView of its own, and with OPERATION_FAILED when WebView2 refuses the factor; that failure carries the zoom in effect.

ParameterTypeRequiredDescription
zoomnumberNoZoom factor; 1 is 100 %. Default: 1.

Returns

FieldTypeDescription
zoomnumberThe zoom factor in effect after the call.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.setZoom', { zoom: 1.25 });

window.setZoomForDpi ​

Set the zoom factor of the calling window's WebView to dpi / 96; as with window.setZoom, the default zoom in the preferences no longer applies to it afterwards. Fails with NOT_FOUND when the calling window has no WebView of its own, and with OPERATION_FAILED when WebView2 refuses the factor; that failure carries the result fields.

ParameterTypeRequiredDescription
dpiintegerNoDPI to match; 0 or less uses the window's DPI, or 96 when it is unknown. Default: 0.

Returns

FieldTypeDescription
dpiintegerThe DPI used.
zoomnumberThe zoom factor in effect after the call.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// omit dpi to derive the zoom from the calling window's current DPI
const res = await fb2k.invoke('window.setZoomForDpi');
if (res.success === false) throw new Error(res.error);
const { zoom } = res;

window.showSystemMenu ​

Open the calling window's system menu (restore, move, size, minimize, maximize, close) and run the command picked from it. Coordinates are screen pixels; fractions are dropped. With a positive w and h the menu opens below the rectangle x, y, w, h and keeps clear of it; otherwise it opens at x, y. Fails in panel mode, when there is no window, and with OPERATION_FAILED when the window has no system menu.

ParameterTypeRequiredDescription
xnumberNoLeft edge of the rectangle to keep clear, or the menu position when w or h is not positive. Default: 0.
ynumberNoTop edge of the rectangle to keep clear, or the menu position when w or h is not positive. Default: 0.
wnumberNoWidth of the rectangle to keep clear. Default: 0.
hnumberNoHeight of the rectangle to keep clear. Default: 0.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
// pass w/h to keep the menu clear of the button that opened it
await fb2k.invoke('window.showSystemMenu', { x: 8, y: 0, w: 32, h: 32 });

window.startDrag ​

Start moving the calling window with the mouse, as pressing its title bar does. Call it from a mousedown handler while the button is still down. Fails in panel mode and when there is no window.

This method takes no parameters.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.startDrag');

window.startResize ​

Start resizing the calling window from one edge or corner with the mouse. Call it from a mousedown handler while the button is still down. Fails in panel mode and when there is no window.

ParameterTypeRequiredDescription
edgestringNoEdge or corner to drag: left, right, top, bottom, topleft, topright, bottomleft or bottomright. Any other value drags the bottom-right corner. Default: "bottomright".

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('window.startResize', { edge: 'bottomright' });

window.toggleAlwaysOnTop ​

Flip whether the calling window is kept above other windows. Fails in panel mode, and with enabled: false when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
enabledbooleanWhether the window is now kept above other windows.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.toggleAlwaysOnTop');

window.toggleFullscreen ​

Enter fullscreen, or leave it when the window is fullscreen. Fails in panel mode.

ParameterTypeRequiredDescription
windowIdstringNoTarget window: main or a popup id; omitted or empty, the calling window. There is no fallback to the main window: a caller that is not one of the plugin's windows fails with NOT_FOUND, and a DUI/CUI panel with PANEL_MODE_UNSUPPORTED.

Returns

FieldTypeDescription
fullscreenbooleanWhether the window is fullscreen now.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.toggleFullscreen');

window.toggleMaximize ​

Maximize the calling window, or restore it when it is maximized. A fullscreen window leaves fullscreen instead. Fails in panel mode, and with maximized: false when there is no window.

This method takes no parameters.

Returns

FieldTypeDescription
maximizedbooleanWhether the window is maximized once the posted request lands. After leaving fullscreen it is the state the window returned to.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('window.toggleMaximize');

Runtime behavior and events ​

  • Caller context and targeting: All window.* calls execute in the calling WebView's context by default. Methods that accept windowId can explicitly target a specific window (main identifies the main window; popup IDs are returned by window.createPopup and window.getAllWindows). In DUI/CUI panel mode, calls requiring a standalone shell fail immediately (reporting unsupported or not-found) instead of silently falling back to the main window.
  • Coordinate scaling: window.setDragRegions, window.setNoDragRegions, window.setMaximizeButtonRegion, and window.setClickThroughExcludeRegions accept CSS-pixel rectangles. The host scales them using the page's devicePixelRatio (combining window DPI, Windows text scale, and page zoom); callers must re-register them whenever devicePixelRatio changes. Popup-only operations (such as click-through and close confirmation) reject main-window targets.
  • State transitions and events:
    • The runtime emits window:stateChanged when shell state changes.
    • A popup configured for close confirmation receives window:beforeClose before closing.
    • Multi-window coordination and lifecycle events include window:popupOpened, window:popupClosed, window:message, window:behaviorChanged, window:backdropStateChanged, window:hoverStateChanged, window:minimizeSuppressed, and window:alwaysOnTopChanged.
    • Event payloads are extensible runtime data; callers should tolerate fields added in future updates.