如何解决Pyautogui 不点击线程或子处理?
我正在尝试打开一个 PDF 文件并使用 pywinauto 在 Adobe 中自动进行文件转换。为此,我想使用 pyautogui 单击菜单。
我这样定义函数:
def call_adobe(path):
os.system('cmd /c ' + path)
def adobe_gui():
btn_location = pyautogui.locateCenterOnScreen('Tools.png')
if btn_location is None:
print('Tools not found')
else:
pyautogui.moveto(btn_location)
pyautogui.click(btn_location,clicks=2)
我尝试了多种打开和单击 pdf 的选项:
- 线程:
x = threading.Thread(target=call_adobe,args=(path,))
y = threading.Thread(target=adobe_gui)
x.start()
y.start()
def adobe_gui(path):
subprocess.Popen(path) # <- HERE
btn_location = pyautogui.locateCenterOnScreen('Tools.png')
if btn_location is None:
print('Tools not found')
else:
pyautogui.moveto(btn_location)
pyautogui.click(btn_location,clicks=2)
adobe_gui(path)
def adobe_gui(path):
os.startfile(path) # <- HERE
btn_location = pyautogui.locateCenterOnScreen('Tools.png')
if btn_location is None:
print('Tools not found')
else:
pyautogui.moveto(btn_location)
pyautogui.click(btn_location,clicks=2)
adobe_gui(path)
- 我将 pyautogui.FAILSAVE 更改为 False
在每种情况下,pdf 都会打开,pyautogui 会将光标移动到按钮上方的正确位置。但它没有点击它!我也没有收到任何错误,它从不打印“找不到工具”。
知道什么可行吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。