├── .gitignore ├── README.md ├── app.js ├── index.html └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PixelColor 2 | > Get pixel color from screen. 3 | 4 |

5 | 6 | ## Usage 7 | 8 | Hover mouse over desired pixel to get color. 9 | 10 | Press Command+Alt+P to pause the app. 11 | 12 | Click the hex code to copy it to the clipboard. 13 | 14 | ## License 15 | 16 | GPL v2 17 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var robot = require("robotjs"); 2 | var gui = require("nw.gui"); 3 | 4 | var win = gui.Window.get(); 5 | var clipboard = gui.Clipboard.get(); 6 | 7 | var timer = null; 8 | var hex; 9 | 10 | //Pause the app so you can copy the color. 11 | var pauseHotkey = { 12 | key: "Ctrl+Alt+P", 13 | active: function() 14 | { 15 | if (timer === null) 16 | { 17 | start(); 18 | } 19 | else 20 | { 21 | clearTimeout(timer); 22 | timer = null; 23 | } 24 | }, 25 | failed: function(msg) 26 | { 27 | console.log(msg); 28 | } 29 | }; 30 | 31 | var shortcut = new gui.Shortcut(pauseHotkey); 32 | 33 | gui.App.registerGlobalHotKey(shortcut); 34 | 35 | //Needed for copy/paste on Mac. 36 | if (process.platform === "darwin") 37 | { 38 | var nativeMenuBar = new gui.Menu( 39 | { 40 | type: "menubar" 41 | }); 42 | nativeMenuBar.createMacBuiltin("PixelColor"); 43 | win.menu = nativeMenuBar; 44 | } 45 | 46 | $(document).on("ready", function() 47 | { 48 | start(); 49 | 50 | $("#color").on("click", function() 51 | { 52 | clipboard.set(hex, "text"); 53 | }); 54 | 55 | }); 56 | 57 | function start() 58 | { 59 | timer = setInterval(function() 60 | { 61 | var mouse = robot.getMousePos(); 62 | hex = robot.getPixelColor(mouse.x, mouse.y); 63 | $("#color").text(hex); 64 | $("body").css("background-color", "#" + hex); 65 | }, 200); 66 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PixelColor 5 | 6 | 7 | 8 | 9 | 10 | 32 | 33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pixelcolor", 3 | "version": "0.0.1", 4 | "description": "Get pixel color under the mouse.", 5 | "main": "index.html", 6 | "window": { 7 | "always-on-top": true, 8 | "toolbar": false, 9 | "width": 150, 10 | "height": 150, 11 | "title": "PixelColor" 12 | }, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "author": "Jason Stallings ", 17 | "license": "GPL-2.0", 18 | "dependencies": { 19 | "robotjs": "^0.2.3" 20 | } 21 | } 22 | --------------------------------------------------------------------------------