-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Windows Scaling issues: screen functions broken #249
Comments
My placeholder workaround in case anyone is coming across the same issue. You need to expose the included opencv installation and then add robotjs and jimp. const cv = require("opencv4nodejs-prebuilt");
const robot = require("robotjs");
const Jimp = require("jimp");
async function findQuitTemp(templateImage, targetCoefficient = 0.9) {
let pic = robot.screen.capture();
const image = new Jimp(pic.width, pic.height);
let pos = 0;
image.scan(0, 0, image.bitmap.width, image.bitmap.height, (x, y, idx) => {
image.bitmap.data[idx + 2] = pic.image.readUInt8(pos++);
image.bitmap.data[idx + 1] = pic.image.readUInt8(pos++);
image.bitmap.data[idx + 0] = pic.image.readUInt8(pos++);
image.bitmap.data[idx + 3] = pic.image.readUInt8(pos++);
});
await image.writeAsync(`${__dirname}/tempresolve.png`);
const target = await cv.imreadAsync(`${__dirname}/tempresolve.png`);
const template = await cv.imreadAsync(`${__dirname}/${templateImage}`);
// Match template (the brightest locations indicate the highest match)
const matched = target.matchTemplate(template, 5);
return matched.minMaxLoc().maxVal >= targetCoefficient;
} |
@kgallimore Just to make sure: I started digging into this issue and gave your workaround script a run. Are you sure it really solves the problem? It actually captures the exact same portion of the screen as The tweaked matching coefficient and a single search run might lead to a different result, tho. |
So it only captured a portion in a test script, but when I used it within my electron application it found the whole screen? But yea as a standalone my work around seems to not work either. I'm actually not sure what's going on right now. The biggest difference (besides being inside an electron application) I can think of is what node version is being used. |
I haven’t checked this yet, but maybe Electron is, in contrast to the plain node executable, scale aware. |
…nt to always capture the full screen content even with scaling applied
…th custom regions
(nut-tree/nut.js#249) Enable DPI awareness when fetching screen conte…
* (#47) Deleted src/buffer_finalizer.h * (#47) Switched to using Buffer::Copy * Fix for screen highlight window minimized intead close * Create LICENSE.md * Add Helper Methods for calculating the required absolute position on the screen * Refactor moveMouse to use SendInput for absolute position movements on windows * Indentation * Add Coord constant * Squash x and y coord methods Make Absolute coord calculation return MMPoint * Call coord calculator with MMPoint * Correct Types and Return values * Import for getMainDisplaySize * Bugfix for lost co-ordinate precision * (nut-tree/nut.js#249) Enable DPI awareness when fetching screen content to always capture the full screen content even with scaling applied * (nut-tree/nut.js#249) Refactor scale calculation to work correctly with custom regions * (nut-tree/nut.js#306) Specify supported os and cpu in package.json to enable Apple Silicon * Remove scan code block * Release/v2.1.3 (#88) * Update changelog for v2.1.3 * Release v2.1.3 Co-authored-by: Gyula Madarasz <[email protected]> Co-authored-by: Reiss Cashmore <[email protected]>
Version
1.7.0
Short overview
Windows Scaling is affecting multiple screen functions, not returning right height/width, messing with screen capture, screen find
Issue occurs on
Detailed error description
console.log(screen.height()); = Promise { 864 }
Actual height: 2160
It is affected by windows scaling(Set to 250%, 864*2.5 = 2160)
Set scaling to 100%:
console.log(screen.height()); = Promise { 2160 }
screen.find is also broken, it doesn't find matches, and the incorrect guesses highlight boxes are also positioned erratically.
screen.capture only captures a portion of the screen based off the scaling number.
Steps to reproduce error
Additional content
The text was updated successfully, but these errors were encountered: