taojy123 / KeymouseGo

类似按键精灵的鼠标键盘录制和自动化操作 模拟点击和键入 | automate mouse clicks and keyboard input
http://taojy123.github.io/KeymouseGo
GNU General Public License v2.0
7.15k stars 1.04k forks source link

win11下如何运行呢 #254

Open trookie2000 opened 1 year ago

trookie2000 commented 1 year ago

将代码git clone下来后,在vscode中不知道怎么运行。在终端按照提示输入:

  1. 安装 Python3
  2. pip install -r requirements-windows.txt
  3. pip install pyinstaller
  4. pyinstaller -F -w --add-data "./assets;assets" KeymouseGo.py 会出现报错 pyinstaller : 无法将“pyinstaller”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1
    • pyinstaller -F -w --add-data "./assets;assets" KeymouseGo.py
    • CategoryInfo : ObjectNotFound: (pyinstaller:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException
ZutJoe commented 1 year ago

4. pyinstaller -F -w --add-data "./assets;assets" KeymouseGo.py 会出现报错 pyinstaller : 无法将“pyinstaller”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1

/path/to/pyinstaller --add-data "./assets;assets" KeymouseGo.py

例:./venv/Scripts/pyinstaller --add-data "./assets;assets" KeymouseGo.py

路径问题,你把 pyinstaller 下下来之后,如果你用的是虚拟环境,就在虚拟环境的目录里找到 pyinstaller.exe 这个可执行文件,一般在 scripts 这个文件夹下,然后在 pyinstaller 前面加上路径;如果不是,就得找到 python 在自己电脑下载依赖的位置,还是在 scripts 文件夹下。

注:如果不在 scripts 文件夹下,那就去 pyinstaller 目录里面找可执行文件,然后把目录换上去就行。

trookie2000 commented 1 year ago

按照您的步骤后,生成了一个KeymouseGo.spec。然后显示信息: 519 INFO: PyInstaller: 5.13.2 519 INFO: Python: 3.11.0 528 INFO: Platform: Windows-10-10.0.22621-SP0 529 INFO: wrote D:\code\python\KeymouseGo.spec 。如果想用vscode调试的话还需要一些什么操作呢?现在运行KeymousGo.py显示在WindowsRecorder.py中出现错误:

name 'SOpenKey' is not defined File "D:\code\python\KeymouseGo\Recorder\WindowsRecorder.py", line 10, in swapmousebuttons = True if QueryValueEx(SOpenKey(HKEY_CURRENT_USER, ^^^^^^^^ File "D:\code\python\KeymouseGo\Recorder__init__.py", line 6, in import Recorder.WindowsRecorder as _Recorder File "D:\code\python\KeymouseGo\UIFunc.py", line 11, in import Recorder File "D:\code\python\KeymouseGo\KeymouseGo.py", line 7, in import UIFunc NameError: name 'SOpenKey' is not defined

trookie2000 commented 1 year ago

而且执行第二步pip install -r requirements-windows.txt的时候会报错。

Defaulting to user installation because normal site-packages is not writeable ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements-windows.txt'

ZutJoe commented 1 year ago

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements-windows.txt'

文件没有找到,你要用到 requirements-windows.txt 就需要在项目根目录执行命令,如果您是刚学 python 您需要再去了解一下 怎么使用 requirements.txt

另外,这里面有个包可能直接从 pip 下不下来,您可以去这个网站下下来,然后本地加载那个包(貌似那个包是 pywinhook 或者 pywin32) https://www.lfd.uci.edu/~gohlke/pythonlibs/

trookie2000 commented 1 year ago

好的~感谢您