Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx committed Aug 20, 2019
2 parents b7e65be + 4ff1a86 commit f54e18a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ Returns `number` - monitor handle.

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

#### win.isVisible() `Windows`
Returns `boolean` - whether the window is visible or not.

#### win.getOwner() `Windows`

Returns [`Window`](#class-window)
Expand Down
5 changes: 5 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ console.timeEnd("getBounds");
console.time("setBounds");
window.setBounds({ x: 0, y: 0 });
console.timeEnd("setBounds");

console.log("[info]: Visible Windows List");
windowManager.getWindows().forEach(window => {
if(window.isVisible()) console.log('Title: '+window.getTitle(), '\n', 'Path: '+window.path);
});
10 changes: 10 additions & 0 deletions lib/windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ Napi::Boolean isWindow(const Napi::CallbackInfo &info) {
return Napi::Boolean::New(env, IsWindow(handle));
}

Napi::Boolean isVisible(const Napi::CallbackInfo &info) {
Napi::Env env{info.Env()};

auto handle{getValueFromCallbackData<HWND>(info, 0)};

return Napi::Boolean::New(env, IsWindowVisible(handle));
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set(Napi::String::New(env, "getActiveWindow"),
Napi::Function::New(env, getActiveWindow));
Expand All @@ -279,6 +287,8 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
Napi::Function::New(env, redrawWindow));
exports.Set(Napi::String::New(env, "isWindow"),
Napi::Function::New(env, isWindow));
exports.Set(Napi::String::New(env, "isVisible"),
Napi::Function::New(env, isVisible));
exports.Set(Napi::String::New(env, "setWindowOpacity"),
Napi::Function::New(env, setWindowOpacity));
exports.Set(Napi::String::New(env, "toggleWindowTransparency"),
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/classes/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export class Window {
else if (platform() === "darwin") return !!this.getInfo();
}

isVisible(): boolean {
if (!addon) return;
if (platform() === "win32") return addon.isVisible(this.id);
}

toggleTransparency(toggle: boolean) {
if (!addon || !addon.toggleWindowTransparency) return;
addon.toggleWindowTransparency(this.id, toggle);
Expand Down

0 comments on commit f54e18a

Please sign in to comment.