node-screenshots icon indicating copy to clipboard operation
node-screenshots copied to clipboard

在win11 electron20和21下scaleFactor错误

Open xushengfeng opened this issue 1 year ago • 3 comments

环境:electron21.3.0,win11 dev 25247 js.js:

const { Screenshots } = require('node-screenshots')

// 获取所有屏幕截图
let all = Screenshots.all() ?? []

all.forEach(capturer => {
  console.log({
    id: capturer.id,
    x: capturer.x,
    y: capturer.y,
    width: capturer.width,
    height: capturer.height,
    rotation: capturer.rotation,
    scaleFactor: capturer.scaleFactor,
    isPrimary: capturer.isPrimary
  })
})

package.json是

{
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "electron": "^21.3.0",
    "node-screenshots": "^0.0.12"
  }
}

直接通过node js.js能输出正确的缩放: 输出:

{
  id: 2779098405,
  x: 0,
  y: 0,
  width: 1536,
  height: 806,
  rotation: 0,
  scaleFactor: 1.25,
  isPrimary: true
}

而通过npx electron js.js则把缩放乘到分辨率中,导致无法获取正确的缩放 输出:

{
  id: 2779098405,
  x: 0,
  y: 0,
  width: 1920,
  height: 1008,
  rotation: 0,
  scaleFactor: 1,
  isPrimary: true
}

xushengfeng avatar Nov 23 '22 15:11 xushengfeng