开发者社区> 镜像站> NPM> window-tracker
window-tracker
Tracks windows and supplies app title+id, window title+id and window bounds.
Last updated 4 years ago by thlorenz .
MIT · Original npm · Tarball · package.json
$ cnpm install window-tracker 
SYNC missed versions from official npm registry.

window tracker

Currently only works on OSX but could be extended to work on Linux and Windows submit those PRs ;)

Installation

npm install window-tracker

demo

Try it

cd node_modules/window-tracker && npm test

API

One time Query Interface

windowTracker.query(cb)

// not using any filters here, so we'll see all windows output

const windowTracker = require('window-tracker')()
windowTracker.query(onresult)

function onresult(err, infos) {
  if (err) return console.error(err)
  console.log(infos)
}
// abbreviated result
[ { app: 'TextEdit',
    appid: 93818,
    window: 'Untitled',
    windowid: 36182,
    bounds: { x: 364, y: 23, w: 842, h: 943 } ]

Tracking Interface

windowTracker.start()

Make sure to subscribe to error and info when using the tracking interface.

const { inspect } = require('util')
const getWindowTracker = require('window-tracker')

// appFilter and windowFilter can be a predicate or a RegExp
const appFilter = /MacVim/i
const windowFilter = /window-tracker/i

const windowTracker = getWindowTracker({ interval: 1000, appFilter, windowFilter })
  .on('error', console.error)
  .on('info', oninfo)
  .start()

let count = 0
function oninfo(info) {
  console.log(inspect(info, false, 5, true))
  if (++count > 20) windowTracker.stop()
}

License

MIT

Current Tags

  • 1.0.1                                ...           latest (4 years ago)

2 Versions

  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None