How to get cursor position outside a window in ElectronJS

Viewed 90

I'm creating a 600 x 300 window in Electronjs and I want to get the cursor position all over the screen, even if the cursor is outside the window. How can I do this?

My window:

let win = new BrowserWindow({
        width: 600,
        height: 300,
        transparent: true,
        show: false,
        webPreferences: {
            contextIsolation: false,
            nodeIntegration: true,
            nodeIntegrationInWorker: true,
        },
    })

I am getting the position this way, but if I move the cursor outside the window it stops working (The windows is focused).

ipcMain.handle('getPoint', async(event, someArgument) => {
        const point = screen.getCursorScreenPoint()
        return point
    })
0 Answers
Related