README
node-window-manager
Manage windows in Windows, macOS and Linux(WIP)
Install
To install this package, just run
$ npm install node-window-manager
Quick start
The following example shows how to get the currently focused window's title and hide it.
const { windowManager } = require("window-manager");
const window = windowManager.getActiveWindow();
// Prints the currently focused window title.
console.log(window.getTitle());
// Moves the window.
window.setBounds({ x: 0, y: 0 });
Documentation
Rectangle
Object x
numbery
numberwidth
numberheight
number
WindowInfo
Object id
numbertitle
stringprocessId
stringpath
string - path to executable associated with the windowbounds
Rectangle
opacity
number (Windows
)owner
Window
(Windows
) - owner window of the current window
WindowManager
Class Instance methods
Windows
macOS
windowManager.getActiveWindow() - Returns
Window
Windows
windowManager.getScaleFactor(monitor: number) - Returns
number
- the monitor scale factor.
Windows
macOS
windowManager.getWindows() - Returns
Window[]
Events
Windows
macOS
Event 'window-activated' Returns:
Emitted when a window has been activated.
Window
Class We try to keep this class similar to Electron's known BrowserWindow
class, to keep it simple to use.
WindowInfo
)
new Window(id: number | id
- this can be either anumber
or aWindowInfo
object.
Instance properties
id
numberprocessId
number - process id associated with the windowpath
string - path to executable associated with the window
Instance methods
Windows
macOS
win.getBounds() - Returns
Rectangle
Windows
macOS
win.setBounds(bounds: Rectangle) Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.
window.setBounds({ height: 50 });
Windows
macOS
win.getInfo() Returns WindowInfo
Windows
macOS
win.getTitle() - Returns
string
Windows
win.show() Shows the window.
Windows
win.hide() Hides the window.
Windows
macOS
win.minimize() Minimizes the window.
Windows
macOS
win.restore() Restores the window.
Windows
win.maximize() Maximizes the window.
Windows
macOS
win.bringToTop() Brings the window to top and focuses it.
Windows
win.setOpacity(opacity: number) opacity
- a value between 0 and 1.
Sets the window opacity.
Windows
win.getOpacity() Gets the window opacity
Returns number
between 0 and 1.
Windows
win.getMonitor() Gets monitor by window.
Returns number
- monitor handle.
Windows
macOS
win.isWindow() Returns boolean
- whether the window is a valid window.
Windows
win.getOwner() Returns Window
Window
| number | null) Windows
win.setOwner(win: win
Window | number | null- pass null to unset window owner.