node-autoit-koffi 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +13 -0
- package/CLAUDE.md +118 -0
- package/README.md +168 -168
- package/biome.json +34 -0
- package/bun.lock +137 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +697 -767
- package/dist/util.d.ts +1 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +24 -14
- package/dist/wchar.d.ts +9 -10
- package/dist/wchar.d.ts.map +1 -1
- package/dist/wchar.js +12 -69
- package/examples/index.test.js +39 -39
- package/package.json +10 -5
package/AGENTS.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
PROJECT RULES AND CONVENTIONS
|
|
4
|
+
|
|
5
|
+
PACKAGE MANAGEMENT
|
|
6
|
+
- This project uses Bun as the package manager instead of npm or yarn
|
|
7
|
+
- Use `bun install` to install dependencies
|
|
8
|
+
- Use `bun add <package>` to add new dependencies
|
|
9
|
+
- Use `bun add -d <package>` to add dev dependencies
|
|
10
|
+
- Use `bun remove <package>` to remove dependencies
|
|
11
|
+
- Use `bun run <script>` to run scripts defined in package.json
|
|
12
|
+
- Do NOT use npm or yarn commands in this project
|
|
13
|
+
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Development Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Build (clean dist/ and compile TypeScript)
|
|
9
|
+
yarn build
|
|
10
|
+
|
|
11
|
+
# Build and run
|
|
12
|
+
yarn start
|
|
13
|
+
|
|
14
|
+
# Run tests (Node.js built-in test runner)
|
|
15
|
+
node examples/index.test.js
|
|
16
|
+
|
|
17
|
+
# Generate TypeScript bindings from AutoIt function definitions
|
|
18
|
+
node tools/generate_code.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Note:** No linting scripts are configured. Prettier is installed but has no format script.
|
|
22
|
+
|
|
23
|
+
## Architecture Overview
|
|
24
|
+
|
|
25
|
+
This is a **Node.js FFI wrapper for AutoIt's Windows automation library** using Koffi. It enables Windows GUI automation (mouse, keyboard, windows) from JavaScript/TypeScript.
|
|
26
|
+
|
|
27
|
+
**Data Flow:**
|
|
28
|
+
```
|
|
29
|
+
User Code → src/index.ts (Promise-wrapped exports) → Koffi FFI → AutoItX3 DLL → Windows API
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Key Components:**
|
|
33
|
+
- **src/index.ts** - Main entry point with 100+ exported AutoIt functions (mostly generated code)
|
|
34
|
+
- **src/util.ts** - DLL path selection (32/64-bit) and wide-string conversion
|
|
35
|
+
- **src/wchar.js** - UTF-16 string handling for Windows (adapted from ref-wchar, MIT)
|
|
36
|
+
- **tools/generate_code.js** - Code generator that creates TypeScript bindings from function definitions
|
|
37
|
+
- **dlls/** - Native AutoItX3 DLLs (32-bit and 64-bit versions)
|
|
38
|
+
|
|
39
|
+
**Critical Dependencies:**
|
|
40
|
+
- `koffi` - FFI library for native DLL calls
|
|
41
|
+
- `iconv-lite` - UTF-16 ↔ UTF-8 conversion
|
|
42
|
+
- `ref-napi` - Buffer/pointer manipulation
|
|
43
|
+
|
|
44
|
+
## Project-Specific Patterns
|
|
45
|
+
|
|
46
|
+
### Generated Code - Do Not Edit Directly
|
|
47
|
+
|
|
48
|
+
Most of `src/index.ts` is **generated** by `tools/generate_code.js`. Look for the `// Generated code:` comment. To add or modify AutoIt function bindings:
|
|
49
|
+
1. Edit the `autoitFunctions` object in `tools/generate_code.js`
|
|
50
|
+
2. Run `node tools/generate_code.js`
|
|
51
|
+
3. Rebuild with `yarn build`
|
|
52
|
+
|
|
53
|
+
### Lazy Function Loading Pattern
|
|
54
|
+
|
|
55
|
+
All FFI functions use lazy loading - bindings are created on first call and cached in the `fn` object:
|
|
56
|
+
```typescript
|
|
57
|
+
if (!fn.hasOwnProperty("functionName")) {
|
|
58
|
+
fn["functionName"] = lib.func("AU3_FunctionName", "returnType", ["paramTypes"]);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Buffer Auto-Expansion for Strings
|
|
63
|
+
|
|
64
|
+
Functions returning strings (like `clipGet`) recursively double buffer size if content is truncated:
|
|
65
|
+
```typescript
|
|
66
|
+
if (content.length === nBufSize - 1) {
|
|
67
|
+
resolve(clipGet(nBufSize * 2)); // Recursive doubling
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Dual API Pattern
|
|
72
|
+
|
|
73
|
+
Most functions have two versions:
|
|
74
|
+
- String-based: `winActivate(szTitle, szText)` - searches for window
|
|
75
|
+
- Handle-based: `winActivateByHandle(hWnd)` - direct, more efficient
|
|
76
|
+
|
|
77
|
+
### Magic Constants
|
|
78
|
+
|
|
79
|
+
- `AU3_INTDEFAULT = -2147483647` - indicates "use default value" for optional parameters
|
|
80
|
+
- Example: `mouseClick("LEFT", AU3_INTDEFAULT, AU3_INTDEFAULT)` clicks at current position
|
|
81
|
+
|
|
82
|
+
### Wide Character Handling
|
|
83
|
+
|
|
84
|
+
Windows uses UTF-16LE. All string parameters use Koffi's `"string16"` type. Buffer allocations multiply by `wchar.size` (2 bytes).
|
|
85
|
+
|
|
86
|
+
### Output Parameters
|
|
87
|
+
|
|
88
|
+
Structs like Point/Rect are passed as output parameters using Koffi's `_Out_` prefix:
|
|
89
|
+
```typescript
|
|
90
|
+
fn["mouseGetPos"] = lib.func("AU3_MouseGetPos", "void", ["_Out_ LPPOINT*"]);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Critical Requirements
|
|
94
|
+
|
|
95
|
+
1. **Windows Only** - Requires AutoItX DLL, no cross-platform support
|
|
96
|
+
2. **Must Call `init()` First** - Always `await autoit.init()` before using any functions
|
|
97
|
+
3. **All Functions Are Async** - Every function returns a Promise
|
|
98
|
+
4. **Architecture-Aware** - Automatically selects 32-bit or 64-bit DLL based on `os.arch()`
|
|
99
|
+
|
|
100
|
+
## Types
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
type Point = { x: number; y: number };
|
|
104
|
+
type Rect = { left: number; top: number; right: number; bottom: number };
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Error Handling
|
|
108
|
+
|
|
109
|
+
- Functions don't validate parameters; rely on AutoIt DLL error codes
|
|
110
|
+
- Errors surface as Promise rejections
|
|
111
|
+
- Use `error()` function to get last AutoIt error code
|
|
112
|
+
|
|
113
|
+
## External Documentation
|
|
114
|
+
|
|
115
|
+
Function behavior and parameters: [AutoIt Documentation](https://www.autoitscript.com/autoit3/docs/functions/)
|
|
116
|
+
|
|
117
|
+
Function naming: `AU3_MouseMove` → `mouseMove` (camelCase conversion)
|
|
118
|
+
|
package/README.md
CHANGED
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
# Node AutoIt Koffi
|
|
2
|
-
|
|
3
|
-
This Node.js module provides support for all AutoIt functions, allowing users to automate Windows GUI tasks seamlessly.
|
|
4
|
-
|
|
5
|
-
## Example
|
|
6
|
-
Check out an example of how to use this module in action: [Example Code](https://github.com/nullmastermind/node-autoit-koffi/blob/master/examples/index.test.js)
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
To install Node AutoIt Koffi, simply run the following command:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install node-autoit-koffi
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
Here's a quick example of how you can use Node AutoIt Koffi in your Node.js application:
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
const autoit = require("node-autoit-koffi");
|
|
20
|
-
|
|
21
|
-
async function main() {
|
|
22
|
-
await autoit.init();
|
|
23
|
-
// Your code here
|
|
24
|
-
await autoit.mouseMove(0, 0);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
main()
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Make sure to refer to the [AutoIt documentation](https://www.autoitscript.com/autoit3/docs/functions/) for a list of supported functions and their usage.
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
type Point = {
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
};
|
|
37
|
-
type Rect = {
|
|
38
|
-
left: number;
|
|
39
|
-
top: number;
|
|
40
|
-
right: number;
|
|
41
|
-
bottom: number;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const init: () => Promise<void>;
|
|
45
|
-
const error: () => Promise<number>;
|
|
46
|
-
const autoItSetOption: (szOption: string, nValue: number) => Promise<number>;
|
|
47
|
-
const clipGet: (nBufSize?: number) => Promise<string>;
|
|
48
|
-
const clipPut: (szClip: string) => Promise<void>;
|
|
49
|
-
const controlClick: (szTitle: string, szText: string | undefined, szControl: string, szButton?: string, nNumClicks?: number, nX?: number, nY?: number) => Promise<number>;
|
|
50
|
-
const controlClickByHandle: (hWnd: number, hCtrl: number, szButton?: string, nNumClicks?: number, nX?: number, nY?: number) => Promise<number>;
|
|
51
|
-
const controlCommand: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra?: string, nBufSize?: number) => Promise<string>;
|
|
52
|
-
const controlCommandByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra?: string, nBufSize?: number) => Promise<string>;
|
|
53
|
-
const controlListView: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
54
|
-
const controlListViewByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
55
|
-
const controlDisable: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
56
|
-
const controlDisableByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
57
|
-
const controlEnable: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
58
|
-
const controlEnableByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
59
|
-
const controlFocus: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
60
|
-
const controlFocusByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
61
|
-
const controlGetFocus: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
62
|
-
const controlGetFocusByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
63
|
-
const controlGetHandle: (hWnd: number, szControl: string) => Promise<number>;
|
|
64
|
-
const controlGetHandleAsText: (szTitle: string, szText: string | undefined, szControl: string, nBufSize?: number) => Promise<string>;
|
|
65
|
-
const controlGetPos: (szTitle: string, szText: string | undefined, szControl: string) => Promise<Rect>;
|
|
66
|
-
const controlGetPosByHandle: (hWnd: number, hCtrl: number) => Promise<Rect>;
|
|
67
|
-
const controlGetText: (szTitle: string, szText: string | undefined, szControl: string, nBufSize?: number) => Promise<string>;
|
|
68
|
-
const controlGetTextByHandle: (hWnd: number, hCtrl: number, nBufSize?: number) => Promise<string>;
|
|
69
|
-
const controlHide: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
70
|
-
const controlHideByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
71
|
-
const controlMove: (szTitle: string, szText: string | undefined, szControl: string, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
72
|
-
const controlMoveByHandle: (hWnd: number, hCtrl: number, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
73
|
-
const controlSend: (szTitle: string, szText: string | undefined, szControl: string, szSendText: string, nMode?: number) => Promise<number>;
|
|
74
|
-
const controlSendByHandle: (hWnd: number, hCtrl: number, szSendText: string, nMode?: number) => Promise<number>;
|
|
75
|
-
const controlSetText: (szTitle: string, szText: string | undefined, szControl: string, szControlText: string) => Promise<number>;
|
|
76
|
-
const controlSetTextByHandle: (hWnd: number, hCtrl: number, szControlText: string) => Promise<number>;
|
|
77
|
-
const controlShow: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
78
|
-
const controlShowByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
79
|
-
const controlTreeView: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
80
|
-
const controlTreeViewByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
81
|
-
const driveMapAdd: (szDevice: string, szShare: string, nFlags: number, szUser?: string, szPwd?: string, nBufSize?: number) => Promise<string>;
|
|
82
|
-
const driveMapDel: (szDevice: string) => Promise<number>;
|
|
83
|
-
const driveMapGet: (szDevice: string, nBufSize?: number) => Promise<string>;
|
|
84
|
-
const isAdmin: () => Promise<number>;
|
|
85
|
-
const mouseClick: (szButton?: string, nX?: number, nY?: number, nClicks?: number, nSpeed?: number) => Promise<number>;
|
|
86
|
-
const mouseClickDrag: (szButton: string, nX1: number, nY1: number, nX2: number, nY2: number, nSpeed?: number) => Promise<number>;
|
|
87
|
-
const mouseDown: (szButton?: string) => Promise<void>;
|
|
88
|
-
const mouseGetCursor: () => Promise<number>;
|
|
89
|
-
const mouseGetPos: () => Promise<Point>;
|
|
90
|
-
const mouseMove: (nX: number, nY: number, nSpeed?: number) => Promise<number>;
|
|
91
|
-
const mouseUp: (szButton?: string) => Promise<void>;
|
|
92
|
-
const mouseWheel: (szDirection: string, nClicks: number) => Promise<void>;
|
|
93
|
-
const opt: (szOption: string, nValue: number) => Promise<number>;
|
|
94
|
-
const pixelChecksum: (lpRect: Rect, nStep?: number) => Promise<number>;
|
|
95
|
-
const pixelGetColor: (nX: number, nY: number) => Promise<number>;
|
|
96
|
-
const pixelSearch: (lpRect: Rect, nCol: number, nVar?: number, nStep?: number) => Promise<Point>;
|
|
97
|
-
const processClose: (szProcess: string) => Promise<number>;
|
|
98
|
-
const processExists: (szProcess: string) => Promise<number>;
|
|
99
|
-
const processSetPriority: (szProcess: string, nPriority: number) => Promise<number>;
|
|
100
|
-
const processWait: (szProcess: string, nTimeout?: number) => Promise<number>;
|
|
101
|
-
const processWaitClose: (szProcess: string, nTimeout?: number) => Promise<number>;
|
|
102
|
-
const run: (szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
103
|
-
const runWait: (szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
104
|
-
const runAs: (szUser: string, szDomain: string, szPassword: string, nLogonFlag: number, szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
105
|
-
const runAsWait: (szUser: string, szDomain: string, szPassword: string, nLogonFlag: number, szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
106
|
-
const send: (szSendText: string, nMode?: number) => Promise<void>;
|
|
107
|
-
const shutdown: (nFlags: number) => Promise<number>;
|
|
108
|
-
const sleep: (nMilliseconds: number) => Promise<void>;
|
|
109
|
-
const statusbarGetText: (szTitle: string, szText?: string, nPart?: number, nBufSize?: number) => Promise<string>;
|
|
110
|
-
const statusbarGetTextByHandle: (hWnd: number, nPart?: number, nBufSize?: number) => Promise<string>;
|
|
111
|
-
const toolTip: (szTip: string, nX?: number, nY?: number) => Promise<void>;
|
|
112
|
-
const winActivate: (szTitle: string, szText?: string) => Promise<number>;
|
|
113
|
-
const winActivateByHandle: (hWnd: number) => Promise<number>;
|
|
114
|
-
const winActive: (szTitle: string, szText: string) => Promise<number>;
|
|
115
|
-
const winActiveByHandle: (hWnd: number) => Promise<number>;
|
|
116
|
-
const winClose: (szTitle: string, szText?: string) => Promise<number>;
|
|
117
|
-
const winCloseByHandle: (hWnd: number) => Promise<number>;
|
|
118
|
-
const winExists: (szTitle: string, szText?: string) => Promise<number>;
|
|
119
|
-
const winExistsByHandle: (hWnd: number) => Promise<number>;
|
|
120
|
-
const winGetCaretPos: () => Promise<Point>;
|
|
121
|
-
const winGetClassList: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
122
|
-
const winGetClassListByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
123
|
-
const winGetClientSize: (szTitle: string, szText?: string) => Promise<Rect>;
|
|
124
|
-
const winGetClientSizeByHandle: (hWnd: number) => Promise<Rect>;
|
|
125
|
-
const winGetHandle: (szTitle: string, szText?: string) => Promise<number>;
|
|
126
|
-
const winGetHandleAsText: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
127
|
-
const winGetPos: (szTitle: string, szText?: string) => Promise<Rect>;
|
|
128
|
-
const winGetPosByHandle: (hWnd: number) => Promise<Rect>;
|
|
129
|
-
const winGetProcess: (szTitle: string, szText?: string) => Promise<number>;
|
|
130
|
-
const winGetProcessByHandle: (hWnd: number) => Promise<number>;
|
|
131
|
-
const winGetState: (szTitle: string, szText?: string) => Promise<number>;
|
|
132
|
-
const winGetStateByHandle: (hWnd: number) => Promise<number>;
|
|
133
|
-
const winGetText: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
134
|
-
const winGetTextByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
135
|
-
const winGetTitle: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
136
|
-
const winGetTitleByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
137
|
-
const winKill: (szTitle: string, szText?: string) => Promise<number>;
|
|
138
|
-
const winKillByHandle: (hWnd: number) => Promise<number>;
|
|
139
|
-
const winMenuSelectItem: (szTitle: string, szText: string | undefined, szItem1: string, szItem2?: string, szItem3?: string, szItem4?: string, szItem5?: string, szItem6?: string, szItem7?: string, szItem8?: string) => Promise<number>;
|
|
140
|
-
const winMenuSelectItemByHandle: (hWnd: number, szItem1: string, szItem2?: string, szItem3?: string, szItem4?: string, szItem5?: string, szItem6?: string, szItem7?: string, szItem8?: string) => Promise<number>;
|
|
141
|
-
const winMinimizeAll: () => Promise<void>;
|
|
142
|
-
const winMinimizeAllUndo: () => Promise<void>;
|
|
143
|
-
const winMove: (szTitle: string, szText: string | undefined, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
144
|
-
const winMoveByHandle: (hWnd: number, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
145
|
-
const winSetOnTop: (szTitle: string, szText: string | undefined, nFlag: number) => Promise<number>;
|
|
146
|
-
const winSetOnTopByHandle: (hWnd: number, nFlag: number) => Promise<number>;
|
|
147
|
-
const winSetState: (szTitle: string, szText: string | undefined, nFlags: number) => Promise<number>;
|
|
148
|
-
const winSetStateByHandle: (hWnd: number, nFlags: number) => Promise<number>;
|
|
149
|
-
const winSetTitle: (szTitle: string, szText: string | undefined, szNewTitle: string) => Promise<number>;
|
|
150
|
-
const winSetTitleByHandle: (hWnd: number, szNewTitle: string) => Promise<number>;
|
|
151
|
-
const winSetTrans: (szTitle: string, szText: string | undefined, nTrans: number) => Promise<number>;
|
|
152
|
-
const winSetTransByHandle: (hWnd: number, nTrans: number) => Promise<number>;
|
|
153
|
-
const winWait: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
154
|
-
const winWaitByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
155
|
-
const winWaitActive: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
156
|
-
const winWaitActiveByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
157
|
-
const winWaitClose: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
158
|
-
const winWaitCloseByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
159
|
-
const winWaitNotActive: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
160
|
-
const winWaitNotActiveByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Support
|
|
164
|
-
If you encounter any issues or have questions, feel free to [open an issue](https://github.com/nullmastermind/node-autoit-koffi/issues) on GitHub.
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
By incorporating Node AutoIt Koffi into your Node.js projects, you can automate Windows GUI tasks efficiently and effectively. Happy coding! 🚀
|
|
1
|
+
# Node AutoIt Koffi
|
|
2
|
+
|
|
3
|
+
This Node.js module provides support for all AutoIt functions, allowing users to automate Windows GUI tasks seamlessly.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
Check out an example of how to use this module in action: [Example Code](https://github.com/nullmastermind/node-autoit-koffi/blob/master/examples/index.test.js)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
To install Node AutoIt Koffi, simply run the following command:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install node-autoit-koffi
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
Here's a quick example of how you can use Node AutoIt Koffi in your Node.js application:
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
const autoit = require("node-autoit-koffi");
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
await autoit.init();
|
|
23
|
+
// Your code here
|
|
24
|
+
await autoit.mouseMove(0, 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void main();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Make sure to refer to the [AutoIt documentation](https://www.autoitscript.com/autoit3/docs/functions/) for a list of supported functions and their usage.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
type Point = {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
type Rect = {
|
|
38
|
+
left: number;
|
|
39
|
+
top: number;
|
|
40
|
+
right: number;
|
|
41
|
+
bottom: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const init: () => Promise<void>;
|
|
45
|
+
const error: () => Promise<number>;
|
|
46
|
+
const autoItSetOption: (szOption: string, nValue: number) => Promise<number>;
|
|
47
|
+
const clipGet: (nBufSize?: number) => Promise<string>;
|
|
48
|
+
const clipPut: (szClip: string) => Promise<void>;
|
|
49
|
+
const controlClick: (szTitle: string, szText: string | undefined, szControl: string, szButton?: string, nNumClicks?: number, nX?: number, nY?: number) => Promise<number>;
|
|
50
|
+
const controlClickByHandle: (hWnd: number, hCtrl: number, szButton?: string, nNumClicks?: number, nX?: number, nY?: number) => Promise<number>;
|
|
51
|
+
const controlCommand: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra?: string, nBufSize?: number) => Promise<string>;
|
|
52
|
+
const controlCommandByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra?: string, nBufSize?: number) => Promise<string>;
|
|
53
|
+
const controlListView: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
54
|
+
const controlListViewByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
55
|
+
const controlDisable: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
56
|
+
const controlDisableByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
57
|
+
const controlEnable: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
58
|
+
const controlEnableByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
59
|
+
const controlFocus: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
60
|
+
const controlFocusByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
61
|
+
const controlGetFocus: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
62
|
+
const controlGetFocusByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
63
|
+
const controlGetHandle: (hWnd: number, szControl: string) => Promise<number>;
|
|
64
|
+
const controlGetHandleAsText: (szTitle: string, szText: string | undefined, szControl: string, nBufSize?: number) => Promise<string>;
|
|
65
|
+
const controlGetPos: (szTitle: string, szText: string | undefined, szControl: string) => Promise<Rect>;
|
|
66
|
+
const controlGetPosByHandle: (hWnd: number, hCtrl: number) => Promise<Rect>;
|
|
67
|
+
const controlGetText: (szTitle: string, szText: string | undefined, szControl: string, nBufSize?: number) => Promise<string>;
|
|
68
|
+
const controlGetTextByHandle: (hWnd: number, hCtrl: number, nBufSize?: number) => Promise<string>;
|
|
69
|
+
const controlHide: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
70
|
+
const controlHideByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
71
|
+
const controlMove: (szTitle: string, szText: string | undefined, szControl: string, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
72
|
+
const controlMoveByHandle: (hWnd: number, hCtrl: number, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
73
|
+
const controlSend: (szTitle: string, szText: string | undefined, szControl: string, szSendText: string, nMode?: number) => Promise<number>;
|
|
74
|
+
const controlSendByHandle: (hWnd: number, hCtrl: number, szSendText: string, nMode?: number) => Promise<number>;
|
|
75
|
+
const controlSetText: (szTitle: string, szText: string | undefined, szControl: string, szControlText: string) => Promise<number>;
|
|
76
|
+
const controlSetTextByHandle: (hWnd: number, hCtrl: number, szControlText: string) => Promise<number>;
|
|
77
|
+
const controlShow: (szTitle: string, szText: string | undefined, szControl: string) => Promise<number>;
|
|
78
|
+
const controlShowByHandle: (hWnd: number, hCtrl: number) => Promise<number>;
|
|
79
|
+
const controlTreeView: (szTitle: string, szText: string | undefined, szControl: string, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
80
|
+
const controlTreeViewByHandle: (hWnd: number, hCtrl: number, szCommand: string, szExtra1?: string, szExtra2?: string, nBufSize?: number) => Promise<string>;
|
|
81
|
+
const driveMapAdd: (szDevice: string, szShare: string, nFlags: number, szUser?: string, szPwd?: string, nBufSize?: number) => Promise<string>;
|
|
82
|
+
const driveMapDel: (szDevice: string) => Promise<number>;
|
|
83
|
+
const driveMapGet: (szDevice: string, nBufSize?: number) => Promise<string>;
|
|
84
|
+
const isAdmin: () => Promise<number>;
|
|
85
|
+
const mouseClick: (szButton?: string, nX?: number, nY?: number, nClicks?: number, nSpeed?: number) => Promise<number>;
|
|
86
|
+
const mouseClickDrag: (szButton: string, nX1: number, nY1: number, nX2: number, nY2: number, nSpeed?: number) => Promise<number>;
|
|
87
|
+
const mouseDown: (szButton?: string) => Promise<void>;
|
|
88
|
+
const mouseGetCursor: () => Promise<number>;
|
|
89
|
+
const mouseGetPos: () => Promise<Point>;
|
|
90
|
+
const mouseMove: (nX: number, nY: number, nSpeed?: number) => Promise<number>;
|
|
91
|
+
const mouseUp: (szButton?: string) => Promise<void>;
|
|
92
|
+
const mouseWheel: (szDirection: string, nClicks: number) => Promise<void>;
|
|
93
|
+
const opt: (szOption: string, nValue: number) => Promise<number>;
|
|
94
|
+
const pixelChecksum: (lpRect: Rect, nStep?: number) => Promise<number>;
|
|
95
|
+
const pixelGetColor: (nX: number, nY: number) => Promise<number>;
|
|
96
|
+
const pixelSearch: (lpRect: Rect, nCol: number, nVar?: number, nStep?: number) => Promise<Point>;
|
|
97
|
+
const processClose: (szProcess: string) => Promise<number>;
|
|
98
|
+
const processExists: (szProcess: string) => Promise<number>;
|
|
99
|
+
const processSetPriority: (szProcess: string, nPriority: number) => Promise<number>;
|
|
100
|
+
const processWait: (szProcess: string, nTimeout?: number) => Promise<number>;
|
|
101
|
+
const processWaitClose: (szProcess: string, nTimeout?: number) => Promise<number>;
|
|
102
|
+
const run: (szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
103
|
+
const runWait: (szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
104
|
+
const runAs: (szUser: string, szDomain: string, szPassword: string, nLogonFlag: number, szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
105
|
+
const runAsWait: (szUser: string, szDomain: string, szPassword: string, nLogonFlag: number, szProgram: string, szDir?: string, nShowFlag?: number) => Promise<number>;
|
|
106
|
+
const send: (szSendText: string, nMode?: number) => Promise<void>;
|
|
107
|
+
const shutdown: (nFlags: number) => Promise<number>;
|
|
108
|
+
const sleep: (nMilliseconds: number) => Promise<void>;
|
|
109
|
+
const statusbarGetText: (szTitle: string, szText?: string, nPart?: number, nBufSize?: number) => Promise<string>;
|
|
110
|
+
const statusbarGetTextByHandle: (hWnd: number, nPart?: number, nBufSize?: number) => Promise<string>;
|
|
111
|
+
const toolTip: (szTip: string, nX?: number, nY?: number) => Promise<void>;
|
|
112
|
+
const winActivate: (szTitle: string, szText?: string) => Promise<number>;
|
|
113
|
+
const winActivateByHandle: (hWnd: number) => Promise<number>;
|
|
114
|
+
const winActive: (szTitle: string, szText: string) => Promise<number>;
|
|
115
|
+
const winActiveByHandle: (hWnd: number) => Promise<number>;
|
|
116
|
+
const winClose: (szTitle: string, szText?: string) => Promise<number>;
|
|
117
|
+
const winCloseByHandle: (hWnd: number) => Promise<number>;
|
|
118
|
+
const winExists: (szTitle: string, szText?: string) => Promise<number>;
|
|
119
|
+
const winExistsByHandle: (hWnd: number) => Promise<number>;
|
|
120
|
+
const winGetCaretPos: () => Promise<Point>;
|
|
121
|
+
const winGetClassList: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
122
|
+
const winGetClassListByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
123
|
+
const winGetClientSize: (szTitle: string, szText?: string) => Promise<Rect>;
|
|
124
|
+
const winGetClientSizeByHandle: (hWnd: number) => Promise<Rect>;
|
|
125
|
+
const winGetHandle: (szTitle: string, szText?: string) => Promise<number>;
|
|
126
|
+
const winGetHandleAsText: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
127
|
+
const winGetPos: (szTitle: string, szText?: string) => Promise<Rect>;
|
|
128
|
+
const winGetPosByHandle: (hWnd: number) => Promise<Rect>;
|
|
129
|
+
const winGetProcess: (szTitle: string, szText?: string) => Promise<number>;
|
|
130
|
+
const winGetProcessByHandle: (hWnd: number) => Promise<number>;
|
|
131
|
+
const winGetState: (szTitle: string, szText?: string) => Promise<number>;
|
|
132
|
+
const winGetStateByHandle: (hWnd: number) => Promise<number>;
|
|
133
|
+
const winGetText: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
134
|
+
const winGetTextByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
135
|
+
const winGetTitle: (szTitle: string, szText?: string, nBufSize?: number) => Promise<string>;
|
|
136
|
+
const winGetTitleByHandle: (hWnd: number, nBufSize?: number) => Promise<string>;
|
|
137
|
+
const winKill: (szTitle: string, szText?: string) => Promise<number>;
|
|
138
|
+
const winKillByHandle: (hWnd: number) => Promise<number>;
|
|
139
|
+
const winMenuSelectItem: (szTitle: string, szText: string | undefined, szItem1: string, szItem2?: string, szItem3?: string, szItem4?: string, szItem5?: string, szItem6?: string, szItem7?: string, szItem8?: string) => Promise<number>;
|
|
140
|
+
const winMenuSelectItemByHandle: (hWnd: number, szItem1: string, szItem2?: string, szItem3?: string, szItem4?: string, szItem5?: string, szItem6?: string, szItem7?: string, szItem8?: string) => Promise<number>;
|
|
141
|
+
const winMinimizeAll: () => Promise<void>;
|
|
142
|
+
const winMinimizeAllUndo: () => Promise<void>;
|
|
143
|
+
const winMove: (szTitle: string, szText: string | undefined, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
144
|
+
const winMoveByHandle: (hWnd: number, nX: number, nY: number, nWidth?: number, nHeight?: number) => Promise<number>;
|
|
145
|
+
const winSetOnTop: (szTitle: string, szText: string | undefined, nFlag: number) => Promise<number>;
|
|
146
|
+
const winSetOnTopByHandle: (hWnd: number, nFlag: number) => Promise<number>;
|
|
147
|
+
const winSetState: (szTitle: string, szText: string | undefined, nFlags: number) => Promise<number>;
|
|
148
|
+
const winSetStateByHandle: (hWnd: number, nFlags: number) => Promise<number>;
|
|
149
|
+
const winSetTitle: (szTitle: string, szText: string | undefined, szNewTitle: string) => Promise<number>;
|
|
150
|
+
const winSetTitleByHandle: (hWnd: number, szNewTitle: string) => Promise<number>;
|
|
151
|
+
const winSetTrans: (szTitle: string, szText: string | undefined, nTrans: number) => Promise<number>;
|
|
152
|
+
const winSetTransByHandle: (hWnd: number, nTrans: number) => Promise<number>;
|
|
153
|
+
const winWait: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
154
|
+
const winWaitByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
155
|
+
const winWaitActive: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
156
|
+
const winWaitActiveByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
157
|
+
const winWaitClose: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
158
|
+
const winWaitCloseByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
159
|
+
const winWaitNotActive: (szTitle: string, szText?: string, nTimeout?: number) => Promise<number>;
|
|
160
|
+
const winWaitNotActiveByHandle: (hWnd: number, nTimeout?: number) => Promise<number>;
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Support
|
|
164
|
+
If you encounter any issues or have questions, feel free to [open an issue](https://github.com/nullmastermind/node-autoit-koffi/issues) on GitHub.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
By incorporating Node AutoIt Koffi into your Node.js projects, you can automate Windows GUI tasks efficiently and effectively. Happy coding! 🚀
|
package/biome.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false,
|
|
10
|
+
"includes": ["src/**"]
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"indentStyle": "space",
|
|
15
|
+
"indentWidth": 2,
|
|
16
|
+
"lineWidth": 100
|
|
17
|
+
},
|
|
18
|
+
"linter": {
|
|
19
|
+
"enabled": true,
|
|
20
|
+
"rules": {
|
|
21
|
+
"recommended": true,
|
|
22
|
+
"suspicious": {
|
|
23
|
+
"noExplicitAny": "off"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"javascript": {
|
|
28
|
+
"formatter": {
|
|
29
|
+
"quoteStyle": "single",
|
|
30
|
+
"semicolons": "always",
|
|
31
|
+
"trailingCommas": "all"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|