gpt4 book ai didi

python - 使用 Pyinstaller 将脚本转换为 exe 后的 PyAutoGui [WinError 2]

转载 作者:可可西里 更新时间:2023-11-01 10:33:40 52 4
gpt4 key购买 nike

我只是想请您帮助解决下面的问题。我的代码运行良好,但在使用 PyInstaller 将其转换为 .exe 后,我会遇到 FileNotFoundError: [WinError 2]

请建议我如何修复它。

FileNotFound:[WinError 2]

代码:

import pyautogui, time

try:
while True:
time.sleep(30)
pyautogui.dragRel(1,0)
pyautogui.dragRel(-1,0)

except KeyboardInterrupt:
print('Done')

最佳答案

我在使用 PyAutoGUI 和 PyInstaller 时遇到了同样的问题,无法让点击工作。移动鼠标和图像识别似乎有效。

感谢这篇帖子吧here我找到了一个“解决方法”:

我没有使用 pyautogoi.click() 方法,而是使用了 ctypes 中的类似方法。

import ctypes

我交换了 pyautogui.click() 调用

# see http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx for details
ctypes.windll.user32.mouse_event(2, 0, 0, 0,0) # left down
ctypes.windll.user32.mouse_event(4, 0, 0, 0,0) # left up

对于双击,我只调用这两个方法两次。

关于python - 使用 Pyinstaller 将脚本转换为 exe 后的 PyAutoGui [WinError 2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39436687/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com