@@ -17,210 +17,19 @@ The following example shows how to get the currently focused window's title and
1717``` javascript
1818const { windowManager } = require (" node-window-manager" );
1919
20- windowManager .requestAccessibility (); // required on macOS
21-
2220const window = windowManager .getActiveWindow ();
2321
24- // Prints the currently focused window title.
25- console .log (window .getTitle ());
22+ // Prints the currently focused window bounds.
23+ console .log (window .getBounds ());
24+
25+ // This method has to be called on macOS before changing the window's bounds, otherwise it will throw an error.
26+ // It will prompt an accessibility permission request dialog, if needed.
27+ windowManager .requestAccessibility ();
2628
27- // Moves the window.
29+ // Sets the active window's bounds .
2830window .setBounds ({ x: 0 , y: 0 });
2931```
3032
3133# Documentation
3234
33- ## Object ` Rectangle `
34-
35- - ` x ` number
36- - ` y ` number
37- - ` width ` number
38- - ` height ` number
39-
40- ## Object ` WindowInfo `
41-
42- - ` title ` string
43- - ` processId ` string
44- - ` path ` string - path to executable associated with the window
45- - ` bounds ` [ ` Rectangle ` ] ( #object-rectangle )
46- - ` opacity ` number (` Windows ` )
47- - ` owner ` [ ` Window ` ] ( #class-window ) (` Windows ` ) - owner window of the current window
48-
49- ## Object ` MonitorInfo `
50-
51- - ` isPrimary ` boolean
52- - ` bounds ` [ ` Rectangle ` ] ( #object-rectangle ) - the monitor position and bounds
53- - ` workArea ` [ ` Rectangle ` ] ( #object-rectangle ) - the monitor working area bounds
54-
55- ## Class ` WindowManager `
56-
57- ### Instance methods
58-
59- #### windowManager.requestAccessibility() ` macOS `
60- Required before any action on macOS.
61- - Returns ` boolean `
62-
63- #### windowManager.getActiveWindow() ` Windows ` ` macOS `
64-
65- - Returns [ ` Window ` ] ( #class-window )
66-
67- #### windowManager.getWindows() ` Windows ` ` macOS `
68-
69- - Returns [ ` Window[] ` ] ( #class-window )
70-
71- #### windowManager.getMonitors() ` Windows `
72-
73- - Returns [ ` Monitor[] ` ] ( #class-monitor )
74-
75- #### windowManager.getPrimaryMonitor() ` Windows `
76-
77- - Returns [ ` Monitor ` ] ( #class-monitor )
78-
79- ### Events
80-
81- #### Event 'window-activated' ` Windows ` ` macOS `
82-
83- Returns:
84-
85- - [ ` Window ` ] ( #class-window )
86-
87- Emitted when a window has been activated.
88-
89- ## Class ` Window `
90-
91- We try to keep this class similar to Electron's known [ ` BrowserWindow ` ] ( https://electronjs.org/docs/api/browser-window ) class, to keep it simple to use.
92-
93- ### new Window(id: number)
94-
95- - ` id ` number
96-
97- ### Instance properties
98-
99- - ` id ` number
100- - ` processId ` number - process id associated with the window
101- - ` path ` string - path to executable associated with the window
102-
103- ### Instance methods
104-
105- #### win.getBounds() ` Windows ` ` macOS `
106-
107- - Returns [ ` Rectangle ` ] ( #object-rectangle )
108-
109- #### win.setBounds(bounds: Rectangle) ` Windows ` ` macOS `
110-
111- Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.
112-
113- ``` javascript
114- window .setBounds ({ height: 50 });
115- ```
116-
117- #### win.getInfo() ` Windows ` ` macOS `
118-
119- Returns [ ` WindowInfo ` ] ( #object-windowinfo )
120-
121- #### win.getTitle() ` Windows ` ` macOS `
122-
123- - Returns ` string `
124-
125- #### win.show() ` Windows `
126-
127- Shows the window.
128-
129- #### win.hide() ` Windows `
130-
131- Hides the window.
132-
133- #### win.minimize() ` Windows ` ` macOS `
134-
135- Minimizes the window.
136-
137- #### win.restore() ` Windows ` ` macOS `
138-
139- Restores the window.
140-
141- #### win.maximize() ` Windows ` ` macOS `
142-
143- Maximizes the window.
144-
145- #### win.bringToTop() ` Windows ` ` macOS `
146-
147- Brings the window to top and focuses it.
148-
149- #### win.setOpacity(opacity: number) ` Windows `
150-
151- - ` opacity ` - a value between 0 and 1.
152-
153- Sets the window opacity.
154-
155- #### win.getOpacity() ` Windows `
156-
157- Gets the window opacity
158-
159- Returns ` number ` between 0 and 1.
160-
161- #### win.getMonitor() ` Windows `
162-
163- Gets monitor which the window belongs to.
164-
165- Returns [ ` Monitor ` ] ( #class-monitor )
166-
167- #### win.isWindow() ` Windows ` ` macOS `
168-
169- Returns ` boolean ` - whether the window is a valid window.
170-
171- #### win.isVisible() ` Windows `
172- Returns ` boolean ` - whether the window is visible or not.
173-
174- #### win.getOwner() ` Windows `
175-
176- Returns [ ` Window ` ] ( #class-window )
177-
178- #### win.setOwner(win: [ ` Window ` ] ( #class-window ) | number | null) ` Windows `
179-
180- - ` win ` [ Window] ( #class-window ) | number | null
181- - pass null to unset window owner.
182-
183- #### win.getIcon(size: number) ` Windows ` ` macOS `
184-
185- - ` size ` number - can be only ` 16 ` , ` 32 ` , ` 64 ` , ` 256 ` . By default it's ` 64 ` .
186-
187- Returns a png Buffer
188-
189-
190- ## Class ` Monitor ` ` Windows `
191-
192- ### new Monitor(id: number)
193-
194- - ` id ` number - the monitor handle
195-
196- ### Instance properties
197-
198- - ` id ` number
199-
200- ### Instance methods
201-
202- #### monitor.getBounds() ` Windows `
203-
204- - Returns [ ` Rectangle ` ] ( #object-rectangle )
205-
206- #### monitor.getWorkArea() ` Windows `
207-
208- Gets monitor working area bounds.
209-
210- - Returns [ ` Rectangle ` ] ( #object-rectangle )
211-
212- #### monitor.getInfo() ` Windows `
213-
214- Returns [ ` MonitorInfo ` ] ( #object-monitorinfo )
215-
216- #### monitor.isPrimary() ` Windows `
217-
218- Whether the monitor is primary.
219-
220- - Returns ` boolean `
221-
222- #### monitor.getScaleFactor() ` Windows `
223-
224- Gets monitor scale factor (DPI).
225-
226- - Returns ` number `
35+ The documentation and API references are located in the [ ` docs ` ] ( docs ) directory.
0 commit comments