js-macro

A npm package that lets you automate your windows desktop.
Examples
Simple cursor usage
const { mouse } = require('js-macro')
mouse.position()
mouse.move(0, 0)
mouse.leftClick()
Typing something on notepad
const { exec } = require('node:child_process')
const { Window, keyboard } = require('js-macro')
exec('notepad.exe')
setTimeout(async () => {
let notepad = await Window.fromProcess('notepad.exe')
if (!notepad) {
return console.error('error: cannot find notepad :(')
}
notepad.focus()
keyboard.type('Hello, World!')
}, 1000)
Copying and pasting programmatically!
const { clipboard } = require('js-macro')
clipboard.copy('Hello, World!')
clipboard.paste()
Click-logging!
const { clicklogger } = require('js-macro')
clicklogger.on('left', coord => console.log(coord))
clicklogger.start()
clicklogger.stop()
Keylogging!
const { keylogger } = require('js-macro')
keylogger.on('word', text => console.log(text))
keylogger.start()
keylogger.stop()
Screenshotting a specific location
const { Screenshot } = require('js-macro')
const screenshot = new Screenshot({
x: 0,
y: 0,
width: 150,
height: 150
})
await screenshot.file('file.png')
Screenshotting your desktop (like print-screen!)
const { Screenshot } = require('js-macro')
const screenshot = new Screenshot()
const buf = await screenshot.buffer('png')