我正在尝试在构建在Azure云上的windows中使用pyautogui自动执行任务。但是当我断开远程连接时,pyautogui进程无法工作。我的代码↓
import time
import pyautogui as pg
pg.hotkey('alt', 'tab') #This line and
for i in range(10):
pg.press(str(i)) #The processing of this line will not be executed.
time.sleep(1)有没有办法在没有远程连接的情况下运行pyautogui?
环境
Azure VM windows 10 python 3.9.7 PyAutoGUI 0.9.53
具体操作如下。
1.在云机上运行my程序。
2.在程序运行时断开与云主机的连接。
3.重新连接并检查程序的结果。
4.错误日志如下。
pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe, set pyautogui.FAILSAFE to False. DISABLING FAIL-SAFE IS NOT RECOMMENDED.但是我尝试了pg.FAILSAFE = True。没有错误,但结果不是正常行为。
发布于 2021-09-20 05:53:19
你必须在云上运行这个程序。我猜你是在你的本地机器上运行它,对吧?
更新:将日志添加到代码中,如下所示:
import logging
logging.basicConfig(filename='logs.log', level=logging.DEBUG, format="%(asctime)s:%(levelname)s: %(message)s")
logging.getLogger().addHandler(logging.StreamHandler())现在您可以找到问题所在了。
发布于 2021-09-20 06:51:18
也许你必须在后台运行programm,所以当你关闭连接或终端时,它不会停止。
一些像this这样的网站可以帮助你。
https://stackoverflow.com/questions/69249525
复制相似问题