DenoPilot is a Windows Desktop automation module for Deno, written in TypeScript. It empowers users to automate various tasks on their Windows systems, enhancing productivity and enabling software testing scenarios.
“How software developers read documentation: Examples speak louder than words.”
― ChatGPT, November 30, 2022
In this example, we demonstrate the capabilities of automation of DenoPilot. The script begins by activating the Notepad, selecting all existing text, deleting it, and replacing it with 'Hello, I'm DenoPilot ...' message. Following this, it captures a screenshot of the Notepad and pastes the image in mspaint. Then it minimizes the notepad, maximizes the mspaint and displays a notification message 'I'm done,'.
Note
Make sure that Notepad and mspaint are open. The script searches for the processes notepad.exe and mspaint.exe
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
import * as mouse from "https://deno.land/x/denopilot/mod_mouse.ts";
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
import * as system from "https://deno.land/x/denopilot/mod_system.ts";
await win.byProcessName("notepad.exe").activate();
await keyboard.selectAll();
await keyboard.sendKey({ key: keyboard.Key.Delete, action: "press" });
await keyboard.typing(
`Hello,
I'm DenoPilot, I'm going to take a screeshot of this window
and paste it into paint, so make sure mspaint is open.`
);
await system.screenshot("ActiveWindow", "*clipboard*");
await win.byProcessName("mspaint.exe").activate();
await keyboard.paste();
await win.byProcessName("mspaint.exe").max();
await win.byProcessName("notepad.exe").min();
await system.balloon({
title: "Deno",
text: "I'm done",
icon: 77,
timeout: 2000,
});
Minimize, maximize, flash, close, move, resize, and restore windows.
Simulate keyboard strokes, enabling automated data input or interaction with applications.
Control the mouse, including movement, left and right clicks, and scrolling.
System actions including beeps, speak, clipboard, tray ballon and notifications.
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
import * as mouse from "https://deno.land/x/denopilot/mod_mouse.ts";
import * as system from "https://deno.land/x/denopilot/mod_system.ts";
The Window Actions Library provides a set of utilities for managing windows on a desktop environment. It includes functions for finding windows based on various criteria and performing actions such as activation, minimization, maximization, and more.
byTitleExact(title: string): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window with exact title then minimize it.
await win.byTitleExact("myfile.txt").min();
byTitleContains(title: string): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window with title contains then flash it.
await win.byTitleContains("myfile.txt").flash();
byTitleStartsWith(title: string): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window which the title starts with, then close it.
await win.byTitleStartsWith("myfile.txt").close();
byTitleEndsWith(title: string): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window which the title ends with, then maximize it.
await win.byTitleEndsWith("myfile.txt").max();
byProcessName(processName: string): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window of the process name 'notepad.exe', then maximize it.
await win.byProcessName("notepad.exe").max();
byProcessId(processId: number): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Find the window of the process ID 1234, then maximize it.
await win.byProcessId(1234).max();
byActiveWindow(): WindowFinder
import * as win from "https://deno.land/x/denopilot/mod_window.ts";
// Maximize the active window
await win.byActiveWindow().max();
Window Finder | Window Action |
---|---|
byActiveWindow byProcessId byProcessName byTitleContains byTitleEndsWith byTitleExact byTitleStartsWith |
activate center close flash focus max / min moveBy normal setSize toggleMax / togggleMin |
This mod
provides utility functions for sending keyboard input.
typing(text: string): Promise<void>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
// Type the string "Hello"
await keyboard.typing("Hello");
sendKey({ key, action }: { key: Key; action: "press" | "down" | "up" }): Promise<number>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
// Press the 'A' key
await keyboard.sendKey({ key: keyboard.Key.A, action: "press" });
copy(): Promise<void>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
await keyboard.copy();
paste(): Promise<void>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
await keyboard.paste();
cut(): Promise<void>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
await keyboard.cut();
selectAll(): Promise<void>
import * as keyboard from "https://deno.land/x/denopilot/mod_keyboard.ts";
await keyboard.selectAll();
This mod
provides TypeScript functions for interacting with the mouse and cursor position. Leveraging the nirCmd tool, these utilities empower users to manipulate the cursor and simulate mouse button actions programmatically.
setCursor(x: number, y: number): Promise<number>
import * as mouse from "https://deno.land/x/denopilot/mod_mouse.ts";
await mouse.setCursor(0, 0);
left(): MouseButton
import * as mouse from "https://deno.land/x/denopilot/mod_mouse.ts";
await mouse.left().click();
//Also you can use left, right and middle buttons
MouseButton
class contains the following actions:
- click: mouse click
- down: mouse button down
- up: mouse button up (release the button)
- doubleClick: mouse button double click
This mod
Allows you access and control various system actions.
Method | Description |
---|---|
balloon | Display a tray ballon. |
beep | Plays a beep. |
clearClipboard | Clear the clipboard. |
infoBox | InfoBox dialog. |
mute | Mute the system sound. |
questionBox | Question Box dialog. |
screenshot | Take a screenshot of monitor, region or window. |
setClipboard | Set the specified text into the clipboard. |
setVolume | Set the computer sound volume. |
speak | Speaks the contents of the text. |
unmute | Unmute the system sound. |
winbeep | Plays the standard beep of Windows. |
This project is licensed under the MIT License