【问题标题】:Typewrite command of pyautogui module is not giving desired outputpyautogui 模块的 typewrite 命令未提供所需的输出
【发布时间】:2020-11-30 19:53:13
【问题描述】:
我使用 pyautogui 模块并执行了以下步骤:
- 已导入 pyautogui。
- 给了
pyautogui.hotkey('winleft')
正常工作并弹出窗口。现在我想启动 chrome。
- 下达命令
pyautogui.typewrite('chrome\n')
它不是启动 chrome ,而是在 IDLE 面板上键入 chrome。
请帮助解决这个问题,因为我想启动 chrome。
操作系统:Windows 10
Python 版本:3.8.1
【问题讨论】:
标签:
python
python-3.x
automation
pyautogui
【解决方案1】:
import webbrowser
url = 'about:blank'
# MacOS
#chrome_path = 'open -a /Applications/Google\ Chrome.app %s'
# Windows
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
# Linux
# chrome_path = '/usr/bin/google-chrome %s'
webbrowser.get(chrome_path).open(url)