You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getPixelColor() doesn't work well with high density display on Windows 10 (possibly on others system as well.) The function seems to use given x, y coordinate and match with the original resolution.
For example, my real screen size is 1920*1080, scaled to 125% in Windows setting. Robotjs reports screen size as 1536*864, and function like moveMouse(x, y) works correctly with coordinate within 1536*864, ie, moveMouse(1536, 864) moved the mouse to bottom-right (real-screen pos: 1920, 1080).
Expected Behavior
getPixelColor() use coordinate after scaled
Example: getPixelColor(1536, 864) return color at (1920, 1080) real-screen pos (using 1920*1080 screen with 125% scale)
Current Behavior
getPixelColor() use coordinate before scaled
Example: getPixelColor(1536, 864) return color at (1536, 864) real-screen pos (using 1920*1080 screen with 125% scale)
^ color at mouse position is wrong
^ after moving a little bit down and right, the color return correctly
Possible Solution
Maybe fix in lower level files?
But I have some workaround, that kinda fix it in the top-left area, just in case someone want the half-baked solution:
// x, y parameters are in range from 0 to getScreenSize()functiongetPixelColor(x,y){varDIM={X: 1920,Y: 1080,};varrobotScreen=robot.getScreenSize();varrobotx=x/robotScreen.width*DIM.X;varroboty=y/robotScreen.height*DIM.Y;returnrobot.getPixelColor(robotx,roboty);}
^ after the workaround
Steps to Reproduce (for bugs)
Set scale of your Windows machine to more than 100%
Try getPixelColor()
Your Environment
RobotJS version: 0.5.1
Node.js version: 8.9.4
npm version: 5.6.0
Operating System: Windows 10 version 1803 build 17134.112
The text was updated successfully, but these errors were encountered:
If you have issues like this, it is because Windows don't give apps the correct resolution. Windows lies to old apps about the resolution to prevent compatibility issues.
To fix this issue and make robotjs capture the whole screen, get the correct resolution, or get the correct pixel position, in High DPI/Scaled screens you should add and app manifest like this:
getPixelColor()
doesn't work well with high density display on Windows 10 (possibly on others system as well.) The function seems to use given x, y coordinate and match with the original resolution.For example, my real screen size is 1920*1080, scaled to 125% in Windows setting. Robotjs reports screen size as 1536*864, and function like
moveMouse(x, y)
works correctly with coordinate within 1536*864, ie,moveMouse(1536, 864)
moved the mouse to bottom-right (real-screen pos: 1920, 1080).Expected Behavior
getPixelColor()
use coordinate after scaledExample:
getPixelColor(1536, 864)
return color at (1920, 1080) real-screen pos(using 1920*1080 screen with 125% scale)
Current Behavior
getPixelColor()
use coordinate before scaledExample:
getPixelColor(1536, 864)
return color at (1536, 864) real-screen pos(using 1920*1080 screen with 125% scale)
^ color at mouse position is wrong
^ after moving a little bit down and right, the color return correctly
Possible Solution
Maybe fix in lower level files?
But I have some workaround, that kinda fix it in the top-left area, just in case someone want the half-baked solution:
^ after the workaround
Steps to Reproduce (for bugs)
Your Environment
The text was updated successfully, but these errors were encountered: