sindresorhus / get-windows

Get metadata about the active window and open windows (title, id, bounds, owner, etc)
MIT License
783 stars 161 forks source link

active-win requires the screen recording permission error #150

Open david-george-axomic opened 1 year ago

david-george-axomic commented 1 year ago

When trying to run activeWindow() on macos m1 arm64, I am getting this error "active-win requires the screen recording permission in “System Preferences". I don't get any prompt to give the screen recording permission either, any idea whats wrong.

Error: Command failed: /Users/davidgeorge/Documents/GitHub/oa-assetsbar-v2/node_modules/active-win/main
    at ChildProcess.exithandler (node:child_process:397:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '/Users/davidgeorge/Documents/GitHub/oa-assetsbar-v2/node_modules/active-win/main',
  stdout: 'active-win requires the screen recording permission in “System Preferences › Security & Privacy › Privacy › Screen Recording”.\n',
  stderr: ''

I'm only trying to run the sample file

const activeWindow = require("active-win");

(async () => {
  console.log(await activeWindow());
  /*
    {
        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'
        },
        url: 'https://sindresorhus.com/unicorn',
        memoryUsage: 11015432
    }
    */
})();
apipaliya commented 1 year ago

@david-george-axomic Use active-win v5.1.3

tom2strobl commented 1 year ago

It used to be only accessibility permissions, now its screen recording as well but in the docs it says only screen recording permissions, but active-win requesting it is pretty flaky and sometimes doesn't happen, sometimes it does, but then the modal is somewhere buried between other windows, it's kinda weird right now. Especially since users are really hesitant to giving screen recording permission nowadays.

@apipaliya it's interesting that the older version did not require the permissions, which seems like quite the regression. We can agree that staying on a very old version is not really the right step into the future.

I'm curious why the old version worked fine and the new requires more permissions 🤔