Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty desktop on MacOS through ElectronJS #156

Closed
tonnyorg opened this issue Jan 30, 2020 · 5 comments
Closed

Empty desktop on MacOS through ElectronJS #156

tonnyorg opened this issue Jan 30, 2020 · 5 comments
Labels

Comments

@tonnyorg
Copy link

tonnyorg commented Jan 30, 2020

Describe the bug
Calling this library from Electron ends up taking screenshots of the empty desktop: it pictures the wallpaper and the top bar, but none of the opened windows show up.

To Reproduce

const screenshot = require('screenshot-desktop')
screenshot.listDisplays().then((displays) => {
      console.log(displays);
      screenshot({ screen: displays[displays.length - 1].id, filename: '/tmp/demo' + displays[displays.length - 1].id + '.png' })
        .then((img) => {
          console.log(img);
        });
    });

Expected behavior
Supposedly it should take a picture of the actual screen (with all the windows opened and so).

Environment (please complete the following information):

  • OS: MacOS Catalina 10.15
  • Engine: Electron
  • Version: 7.1.9
@tonnyorg tonnyorg added the bug label Jan 30, 2020
@bencevans
Copy link
Owner

That's odd, I wonder if it's some sort of security restiction. Under the hood we use the screencapture tool on OSX. Could you try running the following and see if you get the same result?

$ screencapture -x -t jpg out.jpg

@tonnyorg
Copy link
Author

tonnyorg commented Feb 6, 2020

@bencevans I know what the problem is now, you have to enable "Screen Recording" for the app (your ide, your console, or wherever you run the screencapture from).

To fix it: System Preferences -> Securtity & Privacy -> Privacy (tab) -> Screen Recording -> and select the app(s) to allow it.

@tonnyorg tonnyorg closed this as completed Feb 6, 2020
@bencevans
Copy link
Owner

Thanks for sharing!

@sankyn1
Copy link

sankyn1 commented Feb 5, 2021

I am too getting the only desktop in the below mac version if there is any open program it still only takes a screenshot of the desktop in another mac version it is running perfectly I have allowed screen recording still it takes pictures of desktop only

image

@bencevans
Copy link
Owner

@sankyn1 Might need to allow screen recording for a different process. Depending on how you're running it. E.g. If you're running your app from an IDE you may need to allow the IDE the screen recording permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants