2.0.2 • Published 2 years ago
js-macro v2.0.2
js-macro

A npm package that lets you automate your windows desktop.
Examples
Simple cursor usage
const { mouse } = require('js-macro')
mouse.position()
// { x: 679, y: 0 }
mouse.move(0, 0)
// cursor is now at the very left top of the screen
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()
// returns 'Hello, World!'
Click-logging!
const { clicklogger } = require('js-macro')
// add a listener on every left click
// we support left, middle, and right clicks!
clicklogger.on('left', coord => console.log(coord))
// start logging!
clicklogger.start()
// do stuff here... then
// while not required, this is highly recommended
clicklogger.stop()
Keylogging!
const { keylogger } = require('js-macro')
// add a listener on every word (after space is pressed)
// we support raw keys, characters, words, and lines!
// please note that this listens directly to your keyboard
// which means that it can't read things like keyboard shortcuts (e.g: clipboard)
// or shifted keys directly.
keylogger.on('word', text => console.log(text))
// start logging!
keylogger.start()
// do stuff here... then
// while not required, this is highly recommended
keylogger.stop()
Screenshotting a specific location
const { Screenshot } = require('js-macro')
const screenshot = new Screenshot({
x: 0,
y: 0,
width: 150,
height: 150
})
// take screenshot and write it to a file
await screenshot.file('file.png')
Screenshotting your desktop (like print-screen!)
const { Screenshot } = require('js-macro')
// providing no arguments will screenshot the current monitor/screen
const screenshot = new Screenshot()
// take screenshot and write it to a Buffer in a PNG format
// the format can be 'png' or 'jpeg'
const buf = await screenshot.buffer('png')
2.0.2
2 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago