UNPKG

@ahmic/autoit-js

Version:
76 lines (51 loc) 2.53 kB
# AutoIt JS <div align="center"> Node.js bindings for AutoItX3.dll. ![NPM Version](https://img.shields.io/npm/v/%40ahmic%2Fautoit-js) ![GitHub License](https://img.shields.io/github/license/KasimAhmic/autoit-js) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KasimAhmic/autoit-js/build.yml) ![NPM Downloads](https://img.shields.io/npm/dw/%40ahmic%2Fautoit-js) ![GitHub Issues](https://img.shields.io/github/issues/KasimAhmic/autoit-js) ![GitHub Pull Requests](https://img.shields.io/github/issues-pr/KasimAhmic/autoit-js) <a href="https://github.com/KasimAhmic/autoit-js">GitHub</a> | <a href="https://www.npmjs.com/package/@ahmic/autoit-js">NPM</a> | <a href="https://kasimahmic.github.io/autoit-js/">Documentation</a> </div> ## What is AutoIt JS? AutoIt is a Windows automation tool that can be used to automate tasks on Windows. AutoIt provides its own scripting language however, it can be difficult to work with if you need to integrate Windows automation into an existing test suite. Enter AutoIt JS. AutoIt JS wraps the AutoItX3.dll library using [Koffi](https://koffi.dev/) to provide a simple to use interface for AutoIt. It allows you to take your existing JavaScript/TypeScript test suite powered by Playwright/Cypress/Puppeteer/etc. and automate Windows programs with ease. ## Documentation Documentation for this project is generated by typedoc and can be found at [https://kasimahmic.github.io/autoit-js/](https://kasimahmic.github.io/autoit-js/). As all the documentation is generated from the code, the documentation is also available inline in your editor for convenience. ## Example Usage ### New Asynchronous API in v2 You can use the new asynchronous API in async contexts like Playwright and Cypress tests to avoid blocking the event loop and slowing down your tests. ```typescript import { Init, Run, Send, WinClose, WinWaitActive, autoit } from '@ahmic/autoit-js'; autoit.load(); await Init(); await Run('notepad.exe'); await WinWaitActive('[CLASS:Notepad]'); await Send('Hello, World!'); await WinClose('[CLASS:Notepad]'); autoit.unload(); ``` ### Synchronous API For simple scripting tasks, the synchronous API is the preferred way to use AutoIt JS. ```typescript import { InitSync, RunSync, SendSync, WinCloseSync, WinWaitActiveSync, autoit } from '@ahmic/autoit-js'; autoit.load(); InitSync(); RunSync('notepad.exe'); WinWaitActiveSync('[CLASS:Notepad]'); SendSync('Hello, World!'); WinCloseSync('[CLASS:Notepad]'); autoit.unload(); ```