Skip to content

Commit f54e18a

Browse files
committed
2 parents b7e65be + 4ff1a86 commit f54e18a

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ Returns `number` - monitor handle.
153153

154154
Returns `boolean` - whether the window is a valid window.
155155

156+
#### win.isVisible() `Windows`
157+
Returns `boolean` - whether the window is visible or not.
158+
156159
#### win.getOwner() `Windows`
157160

158161
Returns [`Window`](#class-window)

example.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ console.timeEnd("getBounds");
1515
console.time("setBounds");
1616
window.setBounds({ x: 0, y: 0 });
1717
console.timeEnd("setBounds");
18+
19+
console.log("[info]: Visible Windows List");
20+
windowManager.getWindows().forEach(window => {
21+
if(window.isVisible()) console.log('Title: '+window.getTitle(), '\n', 'Path: '+window.path);
22+
});

lib/windows.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ Napi::Boolean isWindow(const Napi::CallbackInfo &info) {
262262
return Napi::Boolean::New(env, IsWindow(handle));
263263
}
264264

265+
Napi::Boolean isVisible(const Napi::CallbackInfo &info) {
266+
Napi::Env env{info.Env()};
267+
268+
auto handle{getValueFromCallbackData<HWND>(info, 0)};
269+
270+
return Napi::Boolean::New(env, IsWindowVisible(handle));
271+
}
272+
265273
Napi::Object Init(Napi::Env env, Napi::Object exports) {
266274
exports.Set(Napi::String::New(env, "getActiveWindow"),
267275
Napi::Function::New(env, getActiveWindow));
@@ -279,6 +287,8 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
279287
Napi::Function::New(env, redrawWindow));
280288
exports.Set(Napi::String::New(env, "isWindow"),
281289
Napi::Function::New(env, isWindow));
290+
exports.Set(Napi::String::New(env, "isVisible"),
291+
Napi::Function::New(env, isVisible));
282292
exports.Set(Napi::String::New(env, "setWindowOpacity"),
283293
Napi::Function::New(env, setWindowOpacity));
284294
exports.Set(Napi::String::New(env, "toggleWindowTransparency"),

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/classes/window.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ export class Window {
144144
else if (platform() === "darwin") return !!this.getInfo();
145145
}
146146

147+
isVisible(): boolean {
148+
if (!addon) return;
149+
if (platform() === "win32") return addon.isVisible(this.id);
150+
}
151+
147152
toggleTransparency(toggle: boolean) {
148153
if (!addon || !addon.toggleWindowTransparency) return;
149154
addon.toggleWindowTransparency(this.id, toggle);

0 commit comments

Comments
 (0)