【问题标题】:Cursor not moving to secondary display in Electron光标未移动到电子中的辅助显示
【发布时间】:2018-11-17 16:05:58
【问题描述】:

我正试图让光标转到辅助显示屏,但它停留在主显示屏上。

我已经参考了以下页面,但我不明白我做错了什么:https://electronjs.org/docs/api/screen

为什么光标没有转到副显示屏?

const electron = require('electron')
const { app, BrowserWindow } = require('electron')

let win

app.on('ready', () => {
  let displays = electron.screen.getAllDisplays()
  let externalDisplay = displays.find((display) => {
    return display.bounds.x !== 0 || display.bounds.y !== 0
  })

  if (externalDisplay) {
    win = new BrowserWindow({
      x: externalDisplay.bounds.x + 50,
      y: externalDisplay.bounds.y + 50
    })
    // win.loadURL('https://github.com');

    secondaryWindow = window.open("secondary.html" + (debug ? "?debug=1" : ""), 'Secondary Display', 'height=100%,width=100%,top=0,left=0,fullscreen=1,status=0,location=0,menubar=0,toolbar=0' );
  }
})

【问题讨论】:

  • 你为什么使用window.open?运行您的代码时我得到ReferenceError: window is not defined
  • 不在主进程中它不是,它不存在那里。
  • 对不起,这段代码能用吗?如果是这样,复制您遇到的问题需要什么?
  • edit 您的问题至少包含您的main.js 文件,该文件最好显示此渲染器进程的加载方式,如果可能,您的package.json
  • "为什么光标没有转到副显示屏?"因为 1. 你根本不尝试移动它 2. electron 不会移动你的鼠标,只需创建一个窗口来告诉它。

标签: javascript node.js electron


【解决方案1】:
  1. 尝试只在主进程中创建新的 BrowserWindow

  2. 在您想要放置它的位置创建一个新窗口,但电子不会移动系统光标

  3. 结帐robotjs,它将完成工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 2021-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多