问题描述
我正在使用pyautogui模块并执行以下步骤:
- 导入的pyautogui。
- 给予
pyautogui.hotkey('winleft')
工作正常,窗口弹出。现在我要启动chrome。
- 发出命令
pyautogui.typewrite('chrome\n')
它没有启动chrome,而是在“空闲”面板上输入chrome。
请帮助解决此问题,因为我想启动chrome。
OS:Windows 10
Python版本:3.8.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)