Skip to content

Commit 85e78dd

Browse files
committed
doc: update document
1 parent 2c09a57 commit 85e78dd

File tree

2 files changed

+61
-93
lines changed

2 files changed

+61
-93
lines changed

README.md

+31-48
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
+ [基本操作](#基本操作)
3333
+ [提示](#提示)
3434
+ [脚本语法说明](#脚本语法说明)
35-
+ [自定义扩展](#自定义扩展)
3635
+ [关于作者](#关于作者)
3736
+ [开源贡献者](#开源贡献者)
3837
+ [更新说明](#更新说明)
@@ -88,18 +87,6 @@
8887
> ./KeymouseGo scripts/0314_1452.txt --runtimes 3
8988
```
9089

91-
以200%的速度运行指定脚本:
92-
```
93-
> ./KeymouseGo scripts/0314_1452.txt -sp 200
94-
> ./KeymouseGo scripts/0314_1452.txt --speed 200
95-
```
96-
97-
加载自定义扩展`MyExtension`运行指定脚本:
98-
```
99-
> ./KeymouseGo scripts/0314_1452.txt -m MyExtension
100-
> ./KeymouseGo scripts/0314_1452.txt --module MyExtension
101-
```
102-
10390
## 提示
10491

10592
1、可设置脚本重复执行的次数,如果为 `0` 即为无限循环。
@@ -118,51 +105,47 @@
118105

119106
8、由于程序速度受限,当输入的鼠标速度大于一定值时脚本将无法以预期的输入速度执行
120107

121-
部分系统环境中,可能出现无法录制完整的鼠标事件的情况,请以管理员身份/root身份运行此工具即可正常使用。
108+
9、部分系统环境中,可能出现无法录制完整的鼠标事件的情况,请以管理员身份/root身份运行此工具即可正常使用。
122109

123-
使用Mac的用户,需要确保程序在辅助功能白名单,如果使用打包的exec文件,则还需要确保终端也在辅助功能白名单。 如果app程序闪退,请尝试给予`~/.qt_material`目录下文件的写权限:
110+
10、使用Mac的用户,需要确保程序在辅助功能白名单,如果使用打包的exec文件,则还需要确保终端也在辅助功能白名单。 如果app程序闪退,请尝试给予`~/.qt_material`目录下文件的写权限:
124111
```bash
125112
chmod -R 770 ~/.qt_material
126113
```
127114

115+
11、对于Linux/Mac用户,如果在以管理员身份运行后仍然存在无法录制或执行的问题,可以参考[pynput的文档](https://pynput.readthedocs.io/en/latest/limitations.html)
116+
128117
## 脚本语法说明
129118
> 演示屏幕分辨率为`1920 * 1080`
130119
120+
脚本为 `json5` 格式,每个最内层的jsonobject代表一个事件
121+
```json5
122+
{
123+
scripts: [
124+
// 开始运行 `3000ms` 后,在屏幕相对坐标 `(0.05208, 0.1852)`即 `(100,200)` 处 `按下鼠标右键`;
125+
{type: "event", event_type: "EM", delay: 3000, action_type: "mouse right down", action: ["0.05208%", "0.1852%"]},
126+
// 等待 `50ms` 后在相同位置 `抬起鼠标右键`;
127+
// 横纵坐标为[-1, -1]时,表示在鼠标当前所在位置执行操作。
128+
{type: "event", event_type: "EM", delay: 50, action_type: "mouse right up", action: [-1, -1]},
129+
// 等待 `1000ms` 后 `按下f键`;
130+
{type: "event", event_type: "EK", delay: 1000, action_type: "key down", action: [70, 'F', 0]},
131+
// 等待 `50ms` 后 `抬起f键`;
132+
{type: "event", event_type: "EK", delay: 50, action_type: "key up", action: [70, 'F', 0]},
133+
// 等待 `100ms` 后,在屏幕相对坐标 `(0.2604, 0.4630)`即 `(500, 500)` 处 `按下鼠标左键`;
134+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse left down", action: ["0.2604%", "0.4630%"]},
135+
// 等待 `100ms` 后,鼠标移动至相对坐标 `(0.2604, 0.5556)`即 `(500, 600)` 位置;
136+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse move", action: ["0.2604%", "0.5556%"]},
137+
// 等待 `100ms` 后,在屏幕相对坐标 `(0.3125, 0.5556)`即 `(600, 600)` 处 `抬起鼠标左键`;
138+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse left up", action: ["0.3125%", "0.5556%"]},
139+
// 等待 `100ms` 后,在当前位置输入 `你好 world` 文字。
140+
{type: "event", event_type: "EX", delay: 100, action_type: "input", action: "你好 world"}
141+
]
142+
}
131143
```
132-
[
133-
[3000, "EM", "mouse right down", ["0.05208%", "0.1852%"]], // 开始运行 `3000ms` 后,在屏幕相对坐标 `(0.05208, 0.1852)`即 `(100,200)` 处 `按下鼠标右键`;
134-
[50, "EM", "mouse right up", ["0.05208%", "0.1852%"]], // 等待 `50ms` 后在相同位置 `抬起鼠标右键`;
135-
[1000, "EK", "key down", [70, "F", 0]], // 等待 `1000ms` 后 `按下f键`;
136-
[50, "EK", "key up", [70, "F", 0]], // 等待 `50ms` 后 `抬起f键`;
137-
[100, "EM", "mouse left down", ["0.2604%", "0.4630%"]], // 等待 `100ms` 后,在屏幕相对坐标 `(0.2604, 0.4630)`即 `(500, 500)` 处 `按下鼠标左键`;
138-
[100, "EM", "mouse move", ["0.2604%", "0.5556%"]], // 等待 `100ms` 后,鼠标移动至相对坐标 `(0.2604, 0.5556)`即 `(500, 600)` 位置;
139-
[100, "EM", "mouse left up", ["0.3125%", "0.5556%"]], // 等待 `100ms` 后,在屏幕相对坐标 `(0.3125, 0.5556)`即 `(600, 600)` 处 `抬起鼠标左键`;
140-
[100, "EX", "input", "你好 world"], // 等待 `100ms` 后,在当前位置输入 `你好 world` 文字。
141-
]
142-
```
143144

144-
脚本为 `json` 格式,每一行代表一次动作:
145-
+ 每行的第 1 个元素表示时间间隔,指的是本次动作与上一次动作之间相隔的时间,单位为毫秒。
146-
+ 每行的第 2 个元素表示鼠标动作或是键盘动作:`EM` 为鼠标,`EK` 为键盘,`EX` 为其他拓展动作。
147-
+ 每行的第 3 个元素表示动作的类型:
148-
+ `mouse left down` 为鼠标左键按下,`mouse left up` 为鼠标左键抬起,
149-
+ `mouse right down` 为鼠标右键按下,`mouse right up` 为鼠标右键抬起,
150-
+ `mouse middle down` 为鼠标中键按下, `mouse middle up` 为鼠标中键抬起,
151-
+ `mouse wheel up` 为鼠标滚轮上滑, `mouse wheel down` 为鼠标滚轮下滑,
152-
+ `key down` 为键盘按键按下,`key up` 为键盘按键抬起,
153-
+ `mouse move` 为鼠标滑过,`input` 输入文字。
154-
+ 每行的第 4 个元素表示具体的动作参数
155-
+ 当为鼠标动作时,由两个子元素构成,分别为鼠标所在的屏幕位置的横纵坐标,
156-
+ 当为键盘动作时,由三个子元素构成,分别是(按键编号, 按键名, 拓展标记),
157-
+ 当为输入文字动作时,为要输入的文字内容。
158-
+ 每行 `//` 后的部分为注释内容。
159-
+ 修改时请严格遵守格式,否则可能导致脚本无法运行,建议修改前先备份一下。
160-
+ 横纵坐标为[-1, -1]时,表示在鼠标当前所在位置执行操作。
161-
162-
163-
## 自定义扩展
164-
165-
功能的使用详见[wiki](https://github.com/taojy123/KeymouseGo/wiki/文档#扩展)
145+
146+
## 高级功能
147+
148+
功能的使用详见[wiki](https://github.com/taojy123/KeymouseGo/wiki/文档#脚本语法)
166149

167150

168151
# 关于作者

README_en-US.md

+30-45
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Usage:
4040
- [Command line mode](#command-line-mode)
4141
- [Tips](#tips)
4242
- [Grammar of scripts](#grammar-of-scripts)
43-
- [Extensions](#extensions)
43+
- [Advanced Operations](#advanced-operations)
4444
- [About me](#about-me)
4545
- [Contributors](#contributors)
4646

@@ -95,18 +95,6 @@ Run specific script for 3 times
9595
> ./KeymouseGo scripts/0314_1452.txt --runtimes 3
9696
```
9797

98-
Run specific script at the speed of 200%
99-
```
100-
> ./KeymouseGo scripts/0314_1452.txt -sp 200
101-
> ./KeymouseGo scripts/0314_1452.txt --speed 200
102-
```
103-
104-
Run specific script with extension `MyExtension`
105-
```
106-
> ./KeymouseGo scripts/0314_1452.txt -m MyExtension
107-
> ./KeymouseGo scripts/0314_1452.txt --module MyExtension
108-
```
109-
11098
## Tips
11199

112100
1. The program will endlessly run the script if run times is set to `0`
@@ -125,50 +113,47 @@ Run specific script with extension `MyExtension`
125113

126114
8. Due to the limitation of execution speed, the running speed cannot be set too high.
127115

128-
In some system environment, there may be circumstances that the mouse events cannot be fully recorded. To settle this, you can run this program as administrator/root.
116+
9. In some system environment, there may be circumstances that the mouse events cannot be fully recorded. To settle this, you can run this program as administrator/root.
129117

130-
For mac users, make sure that application must be white listed under Enable access for assistive devices. You may also need to whitelist terminal application if running from terminal. If the app crashes, you may try to give write permission for directory `~/.qt_material`.
118+
10. For mac users, make sure that application must be white listed under Enable access for assistive devices. You may also need to whitelist terminal application if running from terminal. If the app crashes, you may try to give write permission for directory `~/.qt_material`.
131119
```bash
132120
chmod -R 770 ~/.qt_material
133121
```
134122

123+
11. For Linux/Mac users, if you have problems recording or executing event after running this program as root, you may refer to [documentation of pynput](https://pynput.readthedocs.io/en/latest/limitations.html)
124+
135125
## Grammar of scripts
136126
> Assume that the resolution of screen is `1920 * 1080`
137127
128+
The script is saved in `json5` format, in which each line represents an event
129+
```json5
130+
{
131+
scripts: [
132+
// Press mouse right button at the relative coordinates `(0.05208, 0.1852)`(i.e. absolute coordinates `(100,200)`) after 3000ms
133+
{type: "event", event_type: "EM", delay: 3000, action_type: "mouse right down", action: ["0.05208%", "0.1852%"]},
134+
// Release mouse right button at the coordinates after 50ms
135+
// The mouse event will execute on the position that the cursor is currently in when the coordinate is set to [-1, -1]
136+
{type: "event", event_type: "EM", delay: 50, action_type: "mouse right up", action: [-1, -1]},
137+
// Press key 'f' after 1000ms
138+
{type: "event", event_type: "EK", delay: 1000, action_type: "key down", action: [70, 'F', 0]},
139+
// Release key 'f' after 50ms
140+
{type: "event", event_type: "EK", delay: 50, action_type: "key up", action: [70, 'F', 0]},
141+
// Press mouse left button at the relative coordinates `(0.2604, 0.4630)`(i.e. absolute coordinates `(500,500)`) after 100ms
142+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse left down", action: ["0.2604%", "0.4630%"]},
143+
// Move mouse to the relative coordinates `(0.2604, 0.4630)`(i.e. absolute coordinates `(500,500)`) after 100ms
144+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse move", action: ["0.2604%", "0.5556%"]},
145+
// Release mouse left button at the relative coordinates `(0.3125, 0.5556)`(i.e. absolute coordinates `(600,600)`) after 100ms
146+
{type: "event", event_type: "EM", delay: 100, action_type: "mouse left up", action: ["0.3125%", "0.5556%"]},
147+
// Input 'Hello world' at current coordinate after 100ms
148+
{type: "event", event_type: "EX", delay: 100, action_type: "input", action: "你好 world"}
149+
]
150+
}
138151
```
139-
[
140-
[3000, "EM", "mouse right down", ["0.05208%", "0.1852%"]], // Press mouse right button at the relative coordinates `(0.05208, 0.1852)`(i.e. absolute coordinates `(100,200)`) after 3000ms
141-
[50, "EM", "mouse right up", ["0.05208%", "0.1852%"]], // Release mouse right button at the coordinates after 50ms
142-
[1000, "EK", "key down", [70, "F", 0]], // Press key 'f' after 1000ms
143-
[50, "EK", "key up", [70, "F", 0]], // Release key 'f' after 50ms
144-
[100, "EM", "mouse left down", ["0.2604%", "0.4630%"]], // Press mouse left button at the relative coordinates `(0.2604, 0.4630)`(i.e. absolute coordinates `(500,500)`) after 100ms
145-
[100, "EM", "mouse move", ["0.2604%", "0.5556%"]], // Move mouse to the relative coordinates `(0.2604, 0.4630)`(i.e. absolute coordinates `(500,500)`) after 100ms
146-
[100, "EM", "mouse left up", ["0.3125%", "0.5556%"]], // Release mouse left button at the relative coordinates `(0.3125, 0.5556)`(i.e. absolute coordinates `(600,600)`) after 100ms
147-
[100, "EX", "input", "Hello world"], // Input 'Hello world' at current coordinate after 100ms
148-
]
149-
```
150-
151-
The script is saved in `json` format, in which each line represents a operation
152-
+ The first element of each line is time interval(ms), indicating the interval to previous operation
153-
+ The second element of each line is operation type. `EM` represents mouse, `EK` represents keyboard, `EX` represents extended operation
154-
+ The third element of each line is detailed operation type, including
155-
+ `mouse left down` :press mouse left button `mouse left up` release mouse left button
156-
+ `mouse right down` press mouse right button`mouse right up` release mouse right button
157-
+ `mouse middle down` press mouse middle button `mouse middle up` release mouse middle button
158-
+ `mouse wheel up` mouse wheel slide up `mouse wheel down` mouse wheel slide down
159-
+ `key down` press key `key up` release key
160-
+ `mouse move` move mouse to `input` input text
161-
+ The fourth element of each line is action type
162-
+ If operation type is `EM`, it is consisted of coordinates of mouse.(Both relative coordinates and absolute coordinates are supported)
163-
+ If operation type is `EK`, it is consisted of coordinates of (key number, key name, extension flag)
164-
+ If detailed operation type is `Input`, it is the text to input
165-
+ In each line, comment can be added after `//`
166152
+ It is recommended to back up script before editing. And make sure to follow the format while editing, otherwise it may result in failure of execution.
167-
+ The mouse event will execute on the position that the cursor is currently in when the coordinate is set to [-1, -1]
168153

169-
## Extensions
154+
## Advanced Operations
170155

171-
The usage of exetensions is illustrated in [wiki](https://github.com/taojy123/KeymouseGo/wiki/Document#extension)
156+
Please check [wiki](https://github.com/taojy123/KeymouseGo/wiki/Document#grammar)
172157

173158
# About me
174159

0 commit comments

Comments
 (0)