【发布时间】: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