rust-rpa 0.1.5-beta.5 → 0.1.5
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/README.md +17 -5
- package/index.d.ts +11 -6
- package/package.json +1 -1
- package/rust-rpa.darwin-arm64.node +0 -0
- package/rust-rpa.darwin-x64.node +0 -0
- package/rust-rpa.win32-ia32-msvc.node +0 -0
- package/rust-rpa.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -282,9 +282,10 @@ const primary = monitors.find(m => m.isPrimary());
|
|
|
282
282
|
|
|
283
283
|
**findIcon 参数:**
|
|
284
284
|
- `template: ImageData` - 模板图片(要查找的图标)
|
|
285
|
-
- `options
|
|
286
|
-
- `threshold
|
|
287
|
-
- `regions
|
|
285
|
+
- `options?: MatchOptions` - 可选的匹配选项对象
|
|
286
|
+
- `threshold?: number` - 匹配阈值 (0.0-1.0),默认 0.8
|
|
287
|
+
- `regions?: Array<{x, y, width, height}>` - 可选的搜索区域列表,默认为空(全图搜索)
|
|
288
|
+
- 区域可超出图片边界,会自动裁剪为与图片的交集范围进行查找
|
|
288
289
|
|
|
289
290
|
**MatchOptions 说明:**
|
|
290
291
|
|
|
@@ -353,7 +354,7 @@ interface CaptureImageOptions {
|
|
|
353
354
|
|
|
354
355
|
#### 静态方法
|
|
355
356
|
|
|
356
|
-
- `Mouse.moveTo(x, y): Promise<void>` -
|
|
357
|
+
- `Mouse.moveTo(x, y, duration?): Promise<void>` - 移动鼠标到指定坐标。**duration** 可选,移动动画持续时间(秒),默认为 0(瞬间移动)。如果设置 > 0,鼠标将以平滑动画的方式移动到目标点,动画过程中会触发 mouseMove 事件
|
|
357
358
|
- `Mouse.click(button?): Promise<void>` - 点击鼠标。**button** 可选,可用枚举 `MouseButton.Left` / `MouseButton.Right` 或字符串 `'left'` / `'right'` 等,默认左键
|
|
358
359
|
- `Mouse.doubleClick(button?): Promise<void>` - 双击鼠标,button 同上
|
|
359
360
|
- `Mouse.down(button?): Promise<void>` - 按下鼠标按钮,button 同上
|
|
@@ -550,7 +551,8 @@ if (windows.length > 0) {
|
|
|
550
551
|
const { Mouse, MouseButton, Keyboard, Key } = require('rust-rpa');
|
|
551
552
|
|
|
552
553
|
// 鼠标操作
|
|
553
|
-
await Mouse.moveTo(100, 200); //
|
|
554
|
+
await Mouse.moveTo(100, 200); // 瞬间移动鼠标
|
|
555
|
+
await Mouse.moveTo(100, 200, 0.5); // 平滑动画移动,持续 0.5 秒
|
|
554
556
|
await Mouse.click(MouseButton.Left); // 左键点击
|
|
555
557
|
await Mouse.click(MouseButton.Right); // 右键点击
|
|
556
558
|
await Mouse.doubleClick(); // 双击
|
|
@@ -739,6 +741,9 @@ npm test
|
|
|
739
741
|
- [x] 图像保存到文件
|
|
740
742
|
- [x] 剪贴板操作
|
|
741
743
|
- [x] 窗口操作(置顶、移动、调整大小、父进程查询)
|
|
744
|
+
- [ ] 定位文字findText(text, {prompt: '', model: '', timeout: number})
|
|
745
|
+
- [ ] 等待文字、图标、指定时间
|
|
746
|
+
- [ ] 点击文字、图标等操作
|
|
742
747
|
- [ ] 进程管理
|
|
743
748
|
|
|
744
749
|
## 更新日志
|
|
@@ -746,6 +751,13 @@ npm test
|
|
|
746
751
|
### 0.1.5
|
|
747
752
|
|
|
748
753
|
#### 功能
|
|
754
|
+
- **`Mouse.moveTo` 增强**: 新增可选 `duration` 参数,支持平滑动画移动
|
|
755
|
+
- `duration` 为移动动画持续时间(秒),默认为 0(瞬间移动)
|
|
756
|
+
- 当 `duration > 0` 时,鼠标以平滑动画方式移动到目标点,使用 easeInOutCubic 缓动函数
|
|
757
|
+
- 动画过程中会触发 mouseMove 事件,网页等应用可正常响应鼠标移动
|
|
758
|
+
- **`findIcon` 参数优化**: `options` 参数中的 `threshold` 和 `regions` 字段均改为可选
|
|
759
|
+
- `threshold` 不传时默认使用 0.8
|
|
760
|
+
- `regions` 中的区域可超出图片边界,会自动裁剪为与图片的交集范围进行查找
|
|
749
761
|
- **Window.captureImage 选项 `from`**:新增 `'window'`(默认)与 `'screen'`。设为 `'screen'` 时先截取窗口所在显示器整屏,再自动裁剪为当前窗口与显示器的交集区域(超出显示器的部分忽略)。
|
|
750
762
|
- **Window.captureImage 选项 `region`**:新增可选参数,仅截取指定逻辑像素区域 `{ x, y, width, height }`,不填则截取全图。
|
|
751
763
|
- **Window.captureImage 选项 `auto_size`**:新增可选参数。为 `true` 时,在 Windows 存在 DPI 缩放的情况下自动将图像缩放到逻辑像素宽高(与 `getSize`/`getBounds` 一致)。
|
package/index.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export interface ImageMetadata {
|
|
|
29
29
|
}
|
|
30
30
|
/** 匹配选项 */
|
|
31
31
|
export interface MatchOptionsJs {
|
|
32
|
-
/** 匹配阈值 (0.0-1.0)
|
|
33
|
-
threshold
|
|
32
|
+
/** 匹配阈值 (0.0-1.0),低于此值视为未找到,默认 0.8 */
|
|
33
|
+
threshold?: number
|
|
34
34
|
/** 匹配区域列表,若为空则在整个图片中匹配 */
|
|
35
35
|
regions?: Array<MatchRegion>
|
|
36
36
|
}
|
|
@@ -79,8 +79,8 @@ export interface CaptureImageOptions {
|
|
|
79
79
|
from?: 'window' | 'screen' | null
|
|
80
80
|
/** 仅截取该区域(逻辑像素),不填则截取全图;仅对 Window.captureImage 有效 */
|
|
81
81
|
region?: CaptureRegion | null
|
|
82
|
-
/** 为 true
|
|
83
|
-
|
|
82
|
+
/** 为 true 时,若存在 DPI 缩放,则自动将图像缩放到逻辑像素宽高(与 getSize/getBounds 一致);仅对 Window.captureImage 有效 */
|
|
83
|
+
autoSize?: boolean | null
|
|
84
84
|
}
|
|
85
85
|
/** 窗口尺寸信息 */
|
|
86
86
|
export interface WindowSize {
|
|
@@ -147,8 +147,13 @@ export interface MousePosition {
|
|
|
147
147
|
|
|
148
148
|
/** Mouse 类 - 鼠标控制 */
|
|
149
149
|
export declare class Mouse {
|
|
150
|
-
/**
|
|
151
|
-
|
|
150
|
+
/**
|
|
151
|
+
* 移动鼠标到指定坐标
|
|
152
|
+
* @param x - 目标 x 坐标
|
|
153
|
+
* @param y - 目标 y 坐标
|
|
154
|
+
* @param duration - 可选,移动动画持续时间(秒)。默认为 0,表示瞬间移动。如果设置 > 0,鼠标将以平滑动画的方式移动到目标点
|
|
155
|
+
*/
|
|
156
|
+
static moveTo(x: number, y: number, duration?: number | null): Promise<void>
|
|
152
157
|
/** 点击鼠标按钮。button 可选,可用 MouseButton.Left / 'left' 等,默认左键 */
|
|
153
158
|
static click(button?: MouseButtonType | null): Promise<void>
|
|
154
159
|
/** 双击鼠标按钮。button 取值同 click */
|
package/package.json
CHANGED
|
Binary file
|
package/rust-rpa.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|