@positronjs/mouse-position
v1.0.0
Published
Get the current mouse position on the screen for use in your positron.js app.
Maintainers
Readme
Positron Mouse Position
A lightweight Positron extension that grabs the absolute global X and Y coordinates of the mouse cursor.
Supported Native Environments:
- macOS (Cocoa
NSEvent.mouseLocation) - Windows (user32
GetCursorPos)
Installation
Add this plugin to your Positron application's package.json:
npm i @positronjs/mouse-positionNote: Since it uses the Positron extension engine, it will be automatically discovered and stitched into your application's native binary upon your next npx positron build or npx positron run.
Usage
This extension provides an index.js file with a default asynchronous export. To use it, pass your active Window instance into the function to retrieve the coordinates.
const { Window } = require('positron.js');
const getMousePosition = require('positron-plugin-mouse-position');
const mainWindow = new Window({ width: 800, height: 600 });
mainWindow.on('ready', async () => {
// Await the exported function and pass in your window
const position = await getMousePosition(mainWindow);
console.log(`Mouse X: ${position.x}, Mouse Y: ${position.y}`);
});