Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-macro

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-macro

A npm package that lets you automate your windows desktop.

  • 1.1.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

js-macro CI npm downloads prettier

A npm package that lets you automate your windows desktop.

npm i js-macro

Examples

  • Simple cursor usage
import { cursor } from "js-macro";

cursor.position();
// { x: 679, y: 0 }

cursor.move(0, 0);
// cursor is now at the very left top of the screen

cursor.leftClick();
  • Typing something on notepad
import { Worker, isMainThread } from "node:worker_threads";
import { execSync } from "node:child_process";
import { window, keyboard } from "js-macro";

if (!isMainThread) {
    execSync("notepad.exe");
} else {
    // we don't want for execSync to wait for notepad to exit,
    // so we should use a worker instead
    void new Worker(__filename);
    
    // wait for notepad to start
    setTimeout(() => {
        let notepad = window.find("notepad.exe");
        
        if (!notepad.length) {
            return console.error("error: cannot find notepad :(");
        }
        
        // window.find returns an array - use the first element
        notepad[0].focus();
        
        keyboard.type("Hello, World!");
    }, 1000);
}
  • Copying and pasting programmatically!
import { clipboard } from "js-macro";

clipboard.copy("Hello, World!");

clipboard.paste();
// returns "Hello, World!"
  • Screenshotting a window, or your desktop (like print-screen!)

The buffers will ALWAYS be in a PNG format.

import { window } from "js-macro";
const desktop = window.desktop();

desktop.screenshot(0, 0, "file.png").then(() => console.log("screenshotted!"));
desktop.screenshot(0, 0, 500, 500).then(buf => /* ... */);

Building locally

git clone https://github.com/vierofernando/js-macro.git
cd js-macro
npm install --save-dev --ignore-scripts
npm run install

Keywords

FAQs

Package last updated on 11 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc