This is a modified version of the active-win package. Retrieve metadata about the active window.
Works on macOS 10.14+, Linux (note), and Windows 7+.
npm install magic-active-win
const activeWindow = require('magic-active-win');
(async () => {
console.log(await activeWindow(options));
/* Expected result
{
title: 'Unicorns - Google Search',
id: 5762,
bounds: {
x: 0,
y: 0,
height: 900,
width: 1440
},
owner: {
name: 'Google Chrome',
processId: 310,
bundleId: 'com.google.Chrome',
path: '/Applications/Google Chrome.app'
},
memoryUsage: 11015432
}
*/
})();
Note: options
is a type of object
.
activeWindow(options)
: Get metadata about the active window.activeWindow.sync(options)
: Get metadata about the active window synchronously.activeWindow.getOpenWindows()
:- Get metadata about all open windows.
- Windows are returned in order from front to back.
- Returns
Promise<activeWindow.Result[]>
.
activeWindow.getOpenWindowsSync()
:- Get metadata about all open windows synchronously.
- Windows are returned in order from front to back.
- Returns
activeWindow.Result[]
.
accessibilityPermission
(macOS only)- Type:
boolean
- Default:
true
Enable the accessibility permission check. Setting this to false
will prevent the accessibility permission prompt on macOS versions 10.15 and newer. The url
property won't be retrieved.
screenRecordingPermission
(macOS only)- Type:
boolean
- Default:
true
Enable the screen recording permission check. Setting this to false
will prevent the screen recording permission prompt on macOS versions 10.15 and newer. The title
property in the result will always be set to an empty string.
Returns a Promise<object>
with the result, or Promise<undefined>
if there is no active window or if the information is not available.
platform
(string) -'macos'
|'linux'
|'windows'
title
(string) - Window titleid
(number) - Window identifierbounds
(Object) - Window position and sizex
(number)y
(number)width
(number)height
(number)
owner
(Object) - App that owns the windowname
(string) - Name of the appprocessId
(number) - Process identifierbundleId
(string) - Bundle identifier (macOS only)path
(string) - Path to the app
memoryUsage
(number) - Memory usage by the window owner process
To bypass the gyp
build:
npm install --ignore-scripts
Create new tag:
Check the version
on package.json
and just increment it.
git tag -a version -m "some desciption here"
Push the new tag:
git push --tags
Check the Tags
section on the repository and check if the tag that you pushed exist. If it does, click on it.
On the upper right corner you will see an option to publish a release, click that and then fill the necessary details such as generating the release notes and then proceed to publish.
Make sure you're authenticated with npm
:
npm login
Build MacOS binary: (required so that the latest binary main
will also be published)
npm run build:macos
Then publish the files:
npm publish