I’ve built a custom color picker for my application, and I’d like to let users pick colors with an eye-dropper, like in Photoshop or Sketch.
So the user will click the eye-dropper icon, then they will click anywhere on any of their screens, and then the color under the mouse cursor will be inserted into the color picker.
Is it possible to build this using Electron APIs?
I’m imagining something super hacky and terrible, like…
- Capture all desktops via Desktop Capturer (or at least capture the desktop the mouse is on)
- Cover all screens with transparent windows so I can detect clicks even outside of the
- On click, get cursor coordinates via
window.onBlurinstead of click, since it’s simpler, and then I don’t need transparent windows)
- Look at the captured desktop image to get the color at these coordinates
- Hide all transparent windows and stop capturing desktop
I’m not even sure if that would work, but it seems overkill. Is there a better way, or has anyone done this already?