【问题标题】:Typewrite command of pyautogui module is not giving desired outputpyautogui 模块的 typewrite 命令未提供所需的输出
【发布时间】:2020-11-30 19:53:13
【问题描述】:

我使用 pyautogui 模块并执行了以下步骤:

  1. 已导入 pyautogui。
  2. 给了pyautogui.hotkey('winleft')

正常工作并弹出窗口。现在我想启动 chrome。

  1. 下达命令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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    • 1970-01-01
    • 2016-09-19
    • 2022-01-24
    • 2021-06-05
    • 1970-01-01
    • 2023-03-12
    相关资源
    最近更新 更多