问题描述
我正在尝试打开一个 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 (将#修改为@)