我试图让光标转到辅助显示器,但它停留在主显示器上。
我引用了以下页面,但我不明白我做错了什么: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' );
}
})
最佳答案
尝试只在主进程中创建新的 BrowserWindow
在您想要放置它的位置创建一个新窗口,但 electron 不会移动系统光标
结帐 robotjs ,它将完成工作。
关于javascript - 光标不会移动到 Electron 中的辅助显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53352965/