鱼C论坛

 找回密码
 立即注册
查看: 1913|回复: 6

[已解决]pyautogui里网址后的 回车 为啥不起作用呢?

[复制链接]
发表于 2023-2-28 17:07:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import pyautogui
  2. import time

  3. # Set the text that you want to have read aloud
  4. text = "Hello, this is a test of the Microsoft Edge text-to-speech feature."

  5. # Set the URL of the webpage that contains the text
  6. url = "https://www.sina.com.cn"

  7. # Open the Microsoft Edge browser and navigate to the webpage
  8. pyautogui.hotkey('win', 'r')
  9. pyautogui.typewrite('microsoft-edge:')
  10. pyautogui.press('enter')
  11. time.sleep(3)
  12. pyautogui.typewrite(url)
  13. pyautogui.press('enter')   #这个 enter 为啥不起作用呢?

  14. #pyautogui.click(button='left')
  15. time.sleep(10)
复制代码
最佳答案
2023-2-28 20:43:04
本帖最后由 liuhongrun2022 于 2023-2-28 20:44 编辑

应该是输入法问题罢
试试这个:
  1. import pyautogui
  2. import time

  3. # Set the text that you want to have read aloud
  4. text = "Hello, this is a test of the Microsoft Edge text-to-speech feature."

  5. # Set the URL of the webpage that contains the text
  6. url = "https://www.sina.com.cn"

  7. # Open the Microsoft Edge browser and navigate to the webpage
  8. pyautogui.hotkey('win', 'r')
  9. pyautogui.typewrite('microsoft-edge:')
  10. pyautogui.typewrite(url)
  11. pyautogui.press('enter')
  12. pyautogui.press('enter')   #这个 enter 为啥不起作用呢?

  13. #pyautogui.click(button='left')
  14. time.sleep(10)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-2-28 20:30:06 | 显示全部楼层
我这里运行没有问题呀
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-2-28 20:43:04 | 显示全部楼层    本楼为最佳答案   
本帖最后由 liuhongrun2022 于 2023-2-28 20:44 编辑

应该是输入法问题罢
试试这个:
  1. import pyautogui
  2. import time

  3. # Set the text that you want to have read aloud
  4. text = "Hello, this is a test of the Microsoft Edge text-to-speech feature."

  5. # Set the URL of the webpage that contains the text
  6. url = "https://www.sina.com.cn"

  7. # Open the Microsoft Edge browser and navigate to the webpage
  8. pyautogui.hotkey('win', 'r')
  9. pyautogui.typewrite('microsoft-edge:')
  10. pyautogui.typewrite(url)
  11. pyautogui.press('enter')
  12. pyautogui.press('enter')   #这个 enter 为啥不起作用呢?

  13. #pyautogui.click(button='left')
  14. time.sleep(10)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-2-28 21:42:43 | 显示全部楼层
liuhongrun2022 发表于 2023-2-28 20:43
应该是输入法问题罢
试试这个:

真厉害,的确是输入法问题。
我有2输入法:
英文输入法下,程序没问题。
拼音输入法-中文mode下,有问题
拼音输入法-英文mode下,有问题--->可能是因为有个 : , 所以触发了shift键
------------------------------
你这个无论,中英输入法都行。我还没看明白为啥。
pyautogui.typewrite('microsoft-edge:') 之后没有enter也行,为啥呢?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-2-28 21:44:43 | 显示全部楼层
isdkz 发表于 2023-2-28 20:30
我这里运行没有问题呀

输入法敏感
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-2-28 21:54:23 | 显示全部楼层
blackantt 发表于 2023-2-28 21:42
真厉害,的确是输入法问题。
我有2输入法:
英文输入法下,程序没问题。

先把内容输入进去,第一次回车是输入法的提示,第二次是点击确定(猜的)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-2-28 21:55:48 | 显示全部楼层
blackantt 发表于 2023-2-28 21:42
真厉害,的确是输入法问题。
我有2输入法:
英文输入法下,程序没问题。

他那个相当于直接在运行窗口输入 microsoft-edge:https://www.sina.com.cn

你直接在运行窗口输入 https://www.sina.com.cn 都可以的
  1. import pyautogui
  2. import time

  3. # Set the text that you want to have read aloud
  4. text = "Hello, this is a test of the Microsoft Edge text-to-speech feature."

  5. # Set the URL of the webpage that contains the text
  6. url = "https://www.sina.com.cn"

  7. # Open the Microsoft Edge browser and navigate to the webpage
  8. pyautogui.hotkey('win', 'r')
  9. pyautogui.typewrite(url)
  10. pyautogui.press('enter')

  11. #pyautogui.click(button='left')
  12. time.sleep(10)
复制代码

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-20 10:55

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表