illuma-rpa 1.0.0
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/.github/workflows/publish.yml +129 -0
- package/LICENSE +107 -0
- package/README.md +202 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard.d.ts +82 -0
- package/dist/keyboard.d.ts.map +1 -0
- package/dist/keyboard.js +116 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/mouse.d.ts +61 -0
- package/dist/mouse.d.ts.map +1 -0
- package/dist/mouse.js +107 -0
- package/dist/mouse.js.map +1 -0
- package/dist/native.d.ts +63 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +91 -0
- package/dist/native.js.map +1 -0
- package/dist/screen.d.ts +39 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +43 -0
- package/dist/screen.js.map +1 -0
- package/dist/window.d.ts +61 -0
- package/dist/window.d.ts.map +1 -0
- package/dist/window.js +66 -0
- package/dist/window.js.map +1 -0
- package/libnut-core/CHANGELOG.md +122 -0
- package/libnut-core/LICENSE.md +201 -0
- package/libnut-core/README.md +26 -0
- package/libnut-core/index.d.ts +82 -0
- package/libnut-core/index.js +51 -0
- package/libnut-core/package-lock.json +1430 -0
- package/libnut-core/package.json +59 -0
- package/libnut-core/patch-packagename.js +18 -0
- package/libnut-core/permissionCheck.js +82 -0
- package/package.json +61 -0
- package/src/index.ts +10 -0
- package/src/keyboard.ts +125 -0
- package/src/mouse.ts +114 -0
- package/src/native.ts +103 -0
- package/src/screen.ts +59 -0
- package/src/window.ts +89 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
name: Build & Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
version:
|
|
10
|
+
description: 'Version to publish'
|
|
11
|
+
required: true
|
|
12
|
+
default: '1.0.0'
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build-native:
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- os: windows-latest
|
|
21
|
+
platform: win32
|
|
22
|
+
arch: x64
|
|
23
|
+
- os: macos-13
|
|
24
|
+
platform: darwin
|
|
25
|
+
arch: x64
|
|
26
|
+
- os: macos-14
|
|
27
|
+
platform: darwin
|
|
28
|
+
arch: arm64
|
|
29
|
+
- os: ubuntu-latest
|
|
30
|
+
platform: linux
|
|
31
|
+
arch: x64
|
|
32
|
+
|
|
33
|
+
runs-on: ${{ matrix.os }}
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Setup Node.js
|
|
39
|
+
uses: actions/setup-node@v4
|
|
40
|
+
with:
|
|
41
|
+
node-version: '20'
|
|
42
|
+
registry-url: 'https://registry.npmjs.org'
|
|
43
|
+
|
|
44
|
+
- name: Install Linux dependencies
|
|
45
|
+
if: matrix.platform == 'linux'
|
|
46
|
+
run: |
|
|
47
|
+
sudo apt-get update
|
|
48
|
+
sudo apt-get install -y cmake libxtst-dev libpng++-dev
|
|
49
|
+
|
|
50
|
+
- name: Build native module
|
|
51
|
+
working-directory: libnut-core
|
|
52
|
+
run: |
|
|
53
|
+
npm install
|
|
54
|
+
npm run build:release
|
|
55
|
+
|
|
56
|
+
- name: Create platform package
|
|
57
|
+
shell: bash
|
|
58
|
+
run: |
|
|
59
|
+
PKG_NAME="illuma-rpa-${{ matrix.platform }}-${{ matrix.arch }}"
|
|
60
|
+
VERSION="${{ github.event.inputs.version || github.ref_name }}"
|
|
61
|
+
VERSION="${VERSION#v}" # Remove 'v' prefix if present
|
|
62
|
+
|
|
63
|
+
mkdir -p packages/${PKG_NAME}
|
|
64
|
+
cp libnut-core/build/Release/libnut.node packages/${PKG_NAME}/
|
|
65
|
+
cp libnut-core/index.js packages/${PKG_NAME}/
|
|
66
|
+
cp libnut-core/index.d.ts packages/${PKG_NAME}/
|
|
67
|
+
|
|
68
|
+
cat > packages/${PKG_NAME}/package.json << EOF
|
|
69
|
+
{
|
|
70
|
+
"name": "${PKG_NAME}",
|
|
71
|
+
"version": "${VERSION}",
|
|
72
|
+
"description": "Native bindings for illuma-rpa (${{ matrix.platform }}-${{ matrix.arch }})",
|
|
73
|
+
"main": "index.js",
|
|
74
|
+
"types": "index.d.ts",
|
|
75
|
+
"license": "Apache-2.0",
|
|
76
|
+
"os": ["${{ matrix.platform }}"],
|
|
77
|
+
"cpu": ["${{ matrix.arch }}"],
|
|
78
|
+
"files": ["libnut.node", "index.js", "index.d.ts"]
|
|
79
|
+
}
|
|
80
|
+
EOF
|
|
81
|
+
|
|
82
|
+
- name: Upload artifact
|
|
83
|
+
uses: actions/upload-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: illuma-rpa-${{ matrix.platform }}-${{ matrix.arch }}
|
|
86
|
+
path: packages/illuma-rpa-${{ matrix.platform }}-${{ matrix.arch }}
|
|
87
|
+
|
|
88
|
+
publish:
|
|
89
|
+
needs: build-native
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
|
|
92
|
+
steps:
|
|
93
|
+
- uses: actions/checkout@v4
|
|
94
|
+
|
|
95
|
+
- name: Setup Node.js
|
|
96
|
+
uses: actions/setup-node@v4
|
|
97
|
+
with:
|
|
98
|
+
node-version: '20'
|
|
99
|
+
registry-url: 'https://registry.npmjs.org'
|
|
100
|
+
|
|
101
|
+
- name: Download all artifacts
|
|
102
|
+
uses: actions/download-artifact@v4
|
|
103
|
+
with:
|
|
104
|
+
path: packages
|
|
105
|
+
|
|
106
|
+
- name: List packages
|
|
107
|
+
run: ls -la packages/
|
|
108
|
+
|
|
109
|
+
- name: Publish platform packages
|
|
110
|
+
env:
|
|
111
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
112
|
+
run: |
|
|
113
|
+
for pkg in packages/illuma-rpa-*/; do
|
|
114
|
+
echo "Publishing $pkg"
|
|
115
|
+
cd "$pkg"
|
|
116
|
+
npm publish --access public || echo "Failed to publish $pkg"
|
|
117
|
+
cd -
|
|
118
|
+
done
|
|
119
|
+
|
|
120
|
+
- name: Install dependencies
|
|
121
|
+
run: npm install
|
|
122
|
+
|
|
123
|
+
- name: Build main package
|
|
124
|
+
run: npm run build
|
|
125
|
+
|
|
126
|
+
- name: Publish main package
|
|
127
|
+
env:
|
|
128
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
129
|
+
run: npm publish --access public
|
package/LICENSE
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
48
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
49
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
50
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
51
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
52
|
+
Work and such Derivative Works in Source or Object form.
|
|
53
|
+
|
|
54
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
58
|
+
and otherwise transfer the Work.
|
|
59
|
+
|
|
60
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
61
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
62
|
+
modifications, and in Source or Object form, provided that You
|
|
63
|
+
meet the following conditions:
|
|
64
|
+
|
|
65
|
+
(a) You must give any other recipients of the Work or
|
|
66
|
+
Derivative Works a copy of this License; and
|
|
67
|
+
|
|
68
|
+
(b) You must cause any modified files to carry prominent notices
|
|
69
|
+
stating that You changed the files; and
|
|
70
|
+
|
|
71
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
72
|
+
that You distribute, all copyright, patent, trademark, and
|
|
73
|
+
attribution notices from the Source form of the Work; and
|
|
74
|
+
|
|
75
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
76
|
+
distribution, then any Derivative Works that You distribute must
|
|
77
|
+
include a readable copy of the attribution notices contained
|
|
78
|
+
within such NOTICE file.
|
|
79
|
+
|
|
80
|
+
5. Submission of Contributions.
|
|
81
|
+
|
|
82
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
83
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
84
|
+
|
|
85
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
86
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
87
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
88
|
+
|
|
89
|
+
8. Limitation of Liability.
|
|
90
|
+
|
|
91
|
+
9. Accepting Warranty or Additional Liability.
|
|
92
|
+
|
|
93
|
+
END OF TERMS AND CONDITIONS
|
|
94
|
+
|
|
95
|
+
Copyright 2024 Illuma (based on nut.js by Simon Hofmann)
|
|
96
|
+
|
|
97
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
98
|
+
you may not use this file except in compliance with the License.
|
|
99
|
+
You may obtain a copy of the License at
|
|
100
|
+
|
|
101
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, software
|
|
104
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
105
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
106
|
+
See the License for the specific language governing permissions and
|
|
107
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# illuma-rpa
|
|
2
|
+
|
|
3
|
+
Cross-platform desktop automation for Node.js. Control mouse, keyboard, and capture screenshots programmatically.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/illuma-rpa)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🖱️ **Mouse control** - move, click, double-click, drag, scroll
|
|
11
|
+
- ⌨️ **Keyboard control** - type text, press keys, key combinations
|
|
12
|
+
- 📸 **Screen capture** - full screen or region screenshots
|
|
13
|
+
- 🪟 **Window management** - get active window, list windows, focus, resize
|
|
14
|
+
- 🌐 **Cross-platform** - Windows, macOS, Linux (x64 & ARM64)
|
|
15
|
+
- ⚡ **Pre-built binaries** - no compilation required
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install illuma-rpa
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { mouse, keyboard, screen, Key } from 'illuma-rpa';
|
|
27
|
+
|
|
28
|
+
// Move mouse to position
|
|
29
|
+
await mouse.moveTo(100, 200);
|
|
30
|
+
|
|
31
|
+
// Click
|
|
32
|
+
await mouse.click();
|
|
33
|
+
await mouse.click('right');
|
|
34
|
+
await mouse.doubleClick();
|
|
35
|
+
|
|
36
|
+
// Drag
|
|
37
|
+
await mouse.drag(100, 100, 300, 300);
|
|
38
|
+
|
|
39
|
+
// Scroll
|
|
40
|
+
await mouse.scroll('down', 3);
|
|
41
|
+
|
|
42
|
+
// Type text
|
|
43
|
+
await keyboard.type('Hello, World!');
|
|
44
|
+
|
|
45
|
+
// Press keys
|
|
46
|
+
await keyboard.press(Key.Enter);
|
|
47
|
+
await keyboard.press(Key.Ctrl, Key.C); // Ctrl+C
|
|
48
|
+
|
|
49
|
+
// Take screenshot
|
|
50
|
+
const screenshot = await screen.capture();
|
|
51
|
+
console.log(`Screenshot: ${screenshot.width}x${screenshot.height}`);
|
|
52
|
+
|
|
53
|
+
// Capture region
|
|
54
|
+
const region = await screen.captureRegion(0, 0, 500, 500);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## API Reference
|
|
58
|
+
|
|
59
|
+
### Mouse
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { mouse } from 'illuma-rpa';
|
|
63
|
+
|
|
64
|
+
// Move
|
|
65
|
+
await mouse.moveTo(x, y);
|
|
66
|
+
await mouse.moveSmooth(x, y); // Smooth movement
|
|
67
|
+
|
|
68
|
+
// Click
|
|
69
|
+
await mouse.click(); // Left click
|
|
70
|
+
await mouse.click('right'); // Right click
|
|
71
|
+
await mouse.click('middle'); // Middle click
|
|
72
|
+
await mouse.doubleClick();
|
|
73
|
+
|
|
74
|
+
// Drag
|
|
75
|
+
await mouse.drag(startX, startY, endX, endY);
|
|
76
|
+
|
|
77
|
+
// Scroll
|
|
78
|
+
await mouse.scroll('up', 3);
|
|
79
|
+
await mouse.scroll('down', 3);
|
|
80
|
+
|
|
81
|
+
// Get position
|
|
82
|
+
const pos = mouse.getPosition();
|
|
83
|
+
console.log(pos.x, pos.y);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Keyboard
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { keyboard, Key } from 'illuma-rpa';
|
|
90
|
+
|
|
91
|
+
// Type text
|
|
92
|
+
await keyboard.type('Hello');
|
|
93
|
+
await keyboard.typeDelayed('Hello', 50); // 50ms between chars
|
|
94
|
+
|
|
95
|
+
// Press single key
|
|
96
|
+
await keyboard.press(Key.Enter);
|
|
97
|
+
await keyboard.press(Key.Tab);
|
|
98
|
+
|
|
99
|
+
// Key combinations
|
|
100
|
+
await keyboard.press(Key.Ctrl, Key.C); // Copy
|
|
101
|
+
await keyboard.press(Key.Ctrl, Key.V); // Paste
|
|
102
|
+
await keyboard.press(Key.Alt, Key.Tab); // Switch window
|
|
103
|
+
|
|
104
|
+
// Hold and release
|
|
105
|
+
await keyboard.hold(Key.Shift);
|
|
106
|
+
await keyboard.type('hello'); // Types "HELLO"
|
|
107
|
+
await keyboard.release(Key.Shift);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Screen
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { screen } from 'illuma-rpa';
|
|
114
|
+
|
|
115
|
+
// Full screenshot
|
|
116
|
+
const shot = await screen.capture();
|
|
117
|
+
console.log(shot.width, shot.height);
|
|
118
|
+
console.log(shot.image); // Raw pixel buffer
|
|
119
|
+
|
|
120
|
+
// Region screenshot
|
|
121
|
+
const region = await screen.captureRegion(x, y, width, height);
|
|
122
|
+
|
|
123
|
+
// Get screen size
|
|
124
|
+
const size = screen.getSize();
|
|
125
|
+
console.log(size.width, size.height);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Window
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { window } from 'illuma-rpa';
|
|
132
|
+
|
|
133
|
+
// Get active window
|
|
134
|
+
const active = await window.getActive();
|
|
135
|
+
console.log(active.title);
|
|
136
|
+
|
|
137
|
+
// List all windows
|
|
138
|
+
const windows = await window.getAll();
|
|
139
|
+
|
|
140
|
+
// Focus window
|
|
141
|
+
await window.focus(windowHandle);
|
|
142
|
+
|
|
143
|
+
// Resize/move window
|
|
144
|
+
await window.resize(handle, { width: 800, height: 600 });
|
|
145
|
+
await window.move(handle, { x: 100, y: 100 });
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Key Reference
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { Key } from 'illuma-rpa';
|
|
152
|
+
|
|
153
|
+
// Modifiers
|
|
154
|
+
Key.Ctrl, Key.Alt, Key.Shift, Key.Meta (Win/Cmd)
|
|
155
|
+
|
|
156
|
+
// Navigation
|
|
157
|
+
Key.Up, Key.Down, Key.Left, Key.Right
|
|
158
|
+
Key.Home, Key.End, Key.PageUp, Key.PageDown
|
|
159
|
+
|
|
160
|
+
// Editing
|
|
161
|
+
Key.Enter, Key.Tab, Key.Backspace, Key.Delete, Key.Escape, Key.Space
|
|
162
|
+
|
|
163
|
+
// Function keys
|
|
164
|
+
Key.F1, Key.F2, ... Key.F12
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Use with Electron
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// In Electron main process
|
|
171
|
+
import { mouse, keyboard, screen } from 'illuma-rpa';
|
|
172
|
+
|
|
173
|
+
ipcMain.handle('click', async (_, x, y) => {
|
|
174
|
+
await mouse.moveTo(x, y);
|
|
175
|
+
await mouse.click();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
ipcMain.handle('screenshot', async () => {
|
|
179
|
+
return await screen.capture();
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Building from Source
|
|
184
|
+
|
|
185
|
+
If you need to build the native binaries yourself:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Prerequisites:
|
|
189
|
+
# Windows: npm install -g windows-build-tools
|
|
190
|
+
# macOS: xcode-select --install
|
|
191
|
+
# Linux: sudo apt-get install cmake libxtst-dev libpng++-dev
|
|
192
|
+
|
|
193
|
+
cd libnut-core
|
|
194
|
+
npm install
|
|
195
|
+
npm run build:release
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
Apache-2.0
|
|
201
|
+
|
|
202
|
+
Based on [libnut-core](https://github.com/nut-tree/libnut-core) and [nut.js](https://github.com/nut-tree/nut.js).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* illuma-rpa
|
|
3
|
+
* Cross-platform desktop automation for Node.js
|
|
4
|
+
*/
|
|
5
|
+
export { mouse, Mouse } from './mouse';
|
|
6
|
+
export { keyboard, Keyboard, Key } from './keyboard';
|
|
7
|
+
export { screen, Screen, Screenshot } from './screen';
|
|
8
|
+
export { window, Window, WindowInfo } from './window';
|
|
9
|
+
export { loadNativeBinding } from './native';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* illuma-rpa
|
|
4
|
+
* Cross-platform desktop automation for Node.js
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.loadNativeBinding = exports.Window = exports.window = exports.Screen = exports.screen = exports.Key = exports.Keyboard = exports.keyboard = exports.Mouse = exports.mouse = void 0;
|
|
8
|
+
var mouse_1 = require("./mouse");
|
|
9
|
+
Object.defineProperty(exports, "mouse", { enumerable: true, get: function () { return mouse_1.mouse; } });
|
|
10
|
+
Object.defineProperty(exports, "Mouse", { enumerable: true, get: function () { return mouse_1.Mouse; } });
|
|
11
|
+
var keyboard_1 = require("./keyboard");
|
|
12
|
+
Object.defineProperty(exports, "keyboard", { enumerable: true, get: function () { return keyboard_1.keyboard; } });
|
|
13
|
+
Object.defineProperty(exports, "Keyboard", { enumerable: true, get: function () { return keyboard_1.Keyboard; } });
|
|
14
|
+
Object.defineProperty(exports, "Key", { enumerable: true, get: function () { return keyboard_1.Key; } });
|
|
15
|
+
var screen_1 = require("./screen");
|
|
16
|
+
Object.defineProperty(exports, "screen", { enumerable: true, get: function () { return screen_1.screen; } });
|
|
17
|
+
Object.defineProperty(exports, "Screen", { enumerable: true, get: function () { return screen_1.Screen; } });
|
|
18
|
+
var window_1 = require("./window");
|
|
19
|
+
Object.defineProperty(exports, "window", { enumerable: true, get: function () { return window_1.window; } });
|
|
20
|
+
Object.defineProperty(exports, "Window", { enumerable: true, get: function () { return window_1.Window; } });
|
|
21
|
+
var native_1 = require("./native");
|
|
22
|
+
Object.defineProperty(exports, "loadNativeBinding", { enumerable: true, get: function () { return native_1.loadNativeBinding; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAuC;AAA9B,8FAAA,KAAK,OAAA;AAAE,8FAAA,KAAK,OAAA;AACrB,uCAAqD;AAA5C,oGAAA,QAAQ,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAAE,+FAAA,GAAG,OAAA;AAChC,mCAAsD;AAA7C,gGAAA,MAAM,OAAA;AAAE,gGAAA,MAAM,OAAA;AACvB,mCAAsD;AAA7C,gGAAA,MAAM,OAAA;AAAE,gGAAA,MAAM,OAAA;AACvB,mCAA6C;AAApC,2GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard control module
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Key constants for keyboard input
|
|
6
|
+
*/
|
|
7
|
+
export declare const Key: {
|
|
8
|
+
readonly Ctrl: "control";
|
|
9
|
+
readonly Control: "control";
|
|
10
|
+
readonly Alt: "alt";
|
|
11
|
+
readonly Shift: "shift";
|
|
12
|
+
readonly Meta: "command";
|
|
13
|
+
readonly Win: "command";
|
|
14
|
+
readonly Cmd: "command";
|
|
15
|
+
readonly Up: "up";
|
|
16
|
+
readonly Down: "down";
|
|
17
|
+
readonly Left: "left";
|
|
18
|
+
readonly Right: "right";
|
|
19
|
+
readonly Home: "home";
|
|
20
|
+
readonly End: "end";
|
|
21
|
+
readonly PageUp: "pageup";
|
|
22
|
+
readonly PageDown: "pagedown";
|
|
23
|
+
readonly Enter: "enter";
|
|
24
|
+
readonly Return: "enter";
|
|
25
|
+
readonly Tab: "tab";
|
|
26
|
+
readonly Backspace: "backspace";
|
|
27
|
+
readonly Delete: "delete";
|
|
28
|
+
readonly Escape: "escape";
|
|
29
|
+
readonly Esc: "escape";
|
|
30
|
+
readonly Space: "space";
|
|
31
|
+
readonly Insert: "insert";
|
|
32
|
+
readonly F1: "f1";
|
|
33
|
+
readonly F2: "f2";
|
|
34
|
+
readonly F3: "f3";
|
|
35
|
+
readonly F4: "f4";
|
|
36
|
+
readonly F5: "f5";
|
|
37
|
+
readonly F6: "f6";
|
|
38
|
+
readonly F7: "f7";
|
|
39
|
+
readonly F8: "f8";
|
|
40
|
+
readonly F9: "f9";
|
|
41
|
+
readonly F10: "f10";
|
|
42
|
+
readonly F11: "f11";
|
|
43
|
+
readonly F12: "f12";
|
|
44
|
+
readonly PrintScreen: "printscreen";
|
|
45
|
+
readonly CapsLock: "capslock";
|
|
46
|
+
readonly NumLock: "numlock";
|
|
47
|
+
readonly ScrollLock: "scrolllock";
|
|
48
|
+
};
|
|
49
|
+
export type KeyType = typeof Key[keyof typeof Key] | string;
|
|
50
|
+
export declare class Keyboard {
|
|
51
|
+
private delay;
|
|
52
|
+
/**
|
|
53
|
+
* Set delay between key presses (ms)
|
|
54
|
+
*/
|
|
55
|
+
setDelay(ms: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Type a string of text
|
|
58
|
+
*/
|
|
59
|
+
type(text: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Type text with delay between characters
|
|
62
|
+
*/
|
|
63
|
+
typeDelayed(text: string, delayMs?: number): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Press and release a key or key combination
|
|
66
|
+
*/
|
|
67
|
+
press(...keys: KeyType[]): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Hold a key down
|
|
70
|
+
*/
|
|
71
|
+
hold(...keys: KeyType[]): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Release a held key
|
|
74
|
+
*/
|
|
75
|
+
release(...keys: KeyType[]): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Press a key combination (e.g., Ctrl+C)
|
|
78
|
+
*/
|
|
79
|
+
combo(...keys: KeyType[]): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export declare const keyboard: Keyboard;
|
|
82
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCN,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC;AAE5D,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAK;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAK1B;;OAEG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpE;;OAEG;IACG,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9C;;OAEG;IACG,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C;;OAEG;IACG,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD;;OAEG;IACG,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C;AAGD,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
|
package/dist/keyboard.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Keyboard control module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.keyboard = exports.Keyboard = exports.Key = void 0;
|
|
7
|
+
const native_1 = require("./native");
|
|
8
|
+
/**
|
|
9
|
+
* Key constants for keyboard input
|
|
10
|
+
*/
|
|
11
|
+
exports.Key = {
|
|
12
|
+
// Modifiers
|
|
13
|
+
Ctrl: 'control',
|
|
14
|
+
Control: 'control',
|
|
15
|
+
Alt: 'alt',
|
|
16
|
+
Shift: 'shift',
|
|
17
|
+
Meta: 'command', // Win key on Windows, Cmd on macOS
|
|
18
|
+
Win: 'command',
|
|
19
|
+
Cmd: 'command',
|
|
20
|
+
// Navigation
|
|
21
|
+
Up: 'up',
|
|
22
|
+
Down: 'down',
|
|
23
|
+
Left: 'left',
|
|
24
|
+
Right: 'right',
|
|
25
|
+
Home: 'home',
|
|
26
|
+
End: 'end',
|
|
27
|
+
PageUp: 'pageup',
|
|
28
|
+
PageDown: 'pagedown',
|
|
29
|
+
// Editing
|
|
30
|
+
Enter: 'enter',
|
|
31
|
+
Return: 'enter',
|
|
32
|
+
Tab: 'tab',
|
|
33
|
+
Backspace: 'backspace',
|
|
34
|
+
Delete: 'delete',
|
|
35
|
+
Escape: 'escape',
|
|
36
|
+
Esc: 'escape',
|
|
37
|
+
Space: 'space',
|
|
38
|
+
Insert: 'insert',
|
|
39
|
+
// Function keys
|
|
40
|
+
F1: 'f1', F2: 'f2', F3: 'f3', F4: 'f4',
|
|
41
|
+
F5: 'f5', F6: 'f6', F7: 'f7', F8: 'f8',
|
|
42
|
+
F9: 'f9', F10: 'f10', F11: 'f11', F12: 'f12',
|
|
43
|
+
// Other
|
|
44
|
+
PrintScreen: 'printscreen',
|
|
45
|
+
CapsLock: 'capslock',
|
|
46
|
+
NumLock: 'numlock',
|
|
47
|
+
ScrollLock: 'scrolllock',
|
|
48
|
+
};
|
|
49
|
+
class Keyboard {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.delay = 0;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set delay between key presses (ms)
|
|
55
|
+
*/
|
|
56
|
+
setDelay(ms) {
|
|
57
|
+
this.delay = ms;
|
|
58
|
+
(0, native_1.getNative)().setKeyboardDelay(ms);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Type a string of text
|
|
62
|
+
*/
|
|
63
|
+
async type(text) {
|
|
64
|
+
(0, native_1.getNative)().typeString(text);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Type text with delay between characters
|
|
68
|
+
*/
|
|
69
|
+
async typeDelayed(text, delayMs = 50) {
|
|
70
|
+
// Convert delay to characters per minute
|
|
71
|
+
const cpm = Math.round(60000 / delayMs);
|
|
72
|
+
(0, native_1.getNative)().typeStringDelayed(text, cpm);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Press and release a key or key combination
|
|
76
|
+
*/
|
|
77
|
+
async press(...keys) {
|
|
78
|
+
if (keys.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
if (keys.length === 1) {
|
|
81
|
+
(0, native_1.getNative)().keyTap(keys[0]);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Last key is the main key, others are modifiers
|
|
85
|
+
const mainKey = keys[keys.length - 1];
|
|
86
|
+
const modifiers = keys.slice(0, -1);
|
|
87
|
+
(0, native_1.getNative)().keyTap(mainKey, modifiers);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Hold a key down
|
|
92
|
+
*/
|
|
93
|
+
async hold(...keys) {
|
|
94
|
+
for (const key of keys) {
|
|
95
|
+
(0, native_1.getNative)().keyToggle(key, 'down');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Release a held key
|
|
100
|
+
*/
|
|
101
|
+
async release(...keys) {
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
(0, native_1.getNative)().keyToggle(key, 'up');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Press a key combination (e.g., Ctrl+C)
|
|
108
|
+
*/
|
|
109
|
+
async combo(...keys) {
|
|
110
|
+
await this.press(...keys);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.Keyboard = Keyboard;
|
|
114
|
+
// Export singleton instance
|
|
115
|
+
exports.keyboard = new Keyboard();
|
|
116
|
+
//# sourceMappingURL=keyboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qCAAqC;AAErC;;GAEG;AACU,QAAA,GAAG,GAAG;IACjB,YAAY;IACZ,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,SAAS,EAAG,mCAAmC;IACrD,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IAEd,aAAa;IACb,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,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