# python自动挂机 **Repository Path**: zhouquanstudy/python-auto-hang-up ## Basic Information - **Project Name**: python自动挂机 - **Description**: No description available - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-11 - **Last Updated**: 2025-05-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # python自动挂机 #### 介绍 // todo #### 开发步骤 修改了ui文件后需要执行 pyside6-uic UIView.ui -o UIView.py #### 软件架构 软件架构说明 test # 目录 + [安装](#安装) + [使用方法](#使用方法) + [基本操作](#基本操作) + [提示](#提示) + [脚本语法说明](#脚本语法说明) + [关于作者](#关于作者) + [开源贡献者](#开源贡献者) # 安装 该软件通过 `Python` 语言编写,已打包为可执行文件,未安装 `Python` 的用户可直接下载 [release](https://github.com/taojy123/KeymouseGo/releases) 版本 ,直接点击 `KeymouseGo` 运行 ### 源码打包可执行文件 + Windows ``` 1. 安装 Python3 2. pip install -r requirements-windows.txt 3. pip install pyinstaller 4. pyinstaller -F -w --add-data "./assets;assets" KeymouseGo.py ``` + Linux或Mac ``` 1. 安装 Python3 2. pip3 install -r requirements-universal.txt 3. pip3 install pyinstaller 4. pyinstaller -F -w --add-data "./assets:assets" KeymouseGo.py ``` 打包完成后,可执行文件在项目路径的`dist`文件夹内。 # 使用方法 ## 基本操作 ### 桌面模式 1、点击 `录制` 按钮,开始录制。 2、在计算机上进行任意操作,如点击鼠标、键盘输入,这部分的动作会被记录下来。 3、点击 `结束` 按钮,结束录制。 4、点击 `启动` 按钮,计算机会重复执行一遍第2步中所录制的动作。 ### 命令行模式 直接运行指定脚本: ``` > ./KeymouseGo scripts/0314_1452.txt ``` 运行指定脚本3次: ``` > ./KeymouseGo scripts/0314_1452.txt -rt 3 > ./KeymouseGo scripts/0314_1452.txt --runtimes 3 ``` ## 提示 1、可设置脚本重复执行的次数,如果为 `0` 即为无限循环。 2、默认启动热键为 `F6`,功能等同于 `启动` 按钮;默认终止热键为 `F9`,按下后将会停止正在运行的脚本。 3、录制时只记录鼠标点击动作和键盘动作,不记录鼠标移动轨迹。 4、每次录制结束后都会在 `scripts` 目前下生成一个新的脚本文件。 5、运行前可以在列表中选择一个需要执行的脚本。 6、`scripts` 下的脚本文件内容可以修改,修改时可参考如下所述 `脚本格式说明`。 7、热键设置中的`Middle`指代鼠标中键,`XButton`指代鼠标侧键 8、由于程序速度受限,当输入的鼠标速度大于一定值时脚本将无法以预期的输入速度执行 9、部分系统环境中,可能出现无法录制完整的鼠标事件的情况,请以管理员身份/root身份运行此工具即可正常使用。 10、使用Mac的用户,需要确保程序在辅助功能白名单,如果使用打包的exec文件,则还需要确保终端也在辅助功能白名单。 如果app程序闪退,请尝试给予`~/.qt_material`目录下文件的写权限: ```bash chmod -R 770 ~/.qt_material ``` 11、对于Linux/Mac用户,如果在以管理员身份运行后仍然存在无法录制或执行的问题,可以参考[pynput的文档](https://pynput.readthedocs.io/en/latest/limitations.html) ## 脚本语法说明 > 演示屏幕分辨率为`1920 * 1080` 脚本为 `json5` 格式,每个最内层的jsonobject代表一个事件 ```json5 { scripts: [ // 开始运行 `3000ms` 后,在屏幕相对坐标 `(0.05208, 0.1852)`即 `(100,200)` 处 `按下鼠标右键`; {type: "event", event_type: "EM", delay: 3000, action_type: "mouse right down", action: ["0.05208%", "0.1852%"]}, // 等待 `50ms` 后在相同位置 `抬起鼠标右键`; // 横纵坐标为[-1, -1]时,表示在鼠标当前所在位置执行操作。 {type: "event", event_type: "EM", delay: 50, action_type: "mouse right up", action: [-1, -1]}, // 等待 `1000ms` 后 `按下f键`; {type: "event", event_type: "EK", delay: 1000, action_type: "key down", action: [70, 'F', 0]}, // 等待 `50ms` 后 `抬起f键`; {type: "event", event_type: "EK", delay: 50, action_type: "key up", action: [70, 'F', 0]}, // 等待 `100ms` 后,在屏幕相对坐标 `(0.2604, 0.4630)`即 `(500, 500)` 处 `按下鼠标左键`; {type: "event", event_type: "EM", delay: 100, action_type: "mouse left down", action: ["0.2604%", "0.4630%"]}, // 等待 `100ms` 后,鼠标移动至相对坐标 `(0.2604, 0.5556)`即 `(500, 600)` 位置; {type: "event", event_type: "EM", delay: 100, action_type: "mouse move", action: ["0.2604%", "0.5556%"]}, // 等待 `100ms` 后,在屏幕相对坐标 `(0.3125, 0.5556)`即 `(600, 600)` 处 `抬起鼠标左键`; {type: "event", event_type: "EM", delay: 100, action_type: "mouse left up", action: ["0.3125%", "0.5556%"]}, // 等待 `100ms` 后,在当前位置输入 `你好 world` 文字。 {type: "event", event_type: "EX", delay: 100, action_type: "input", action: "你好 world"} ] } ``` ## 高级功能 功能的使用详见[wiki](https://github.com/taojy123/KeymouseGo/wiki/文档#脚本语法)