英文:
PyAutoGui isn't pressing "enter"
问题
I'm trying to get python to automate sending a message in Roblox and it's typing out the message, but it's not sending it by pressing "enter", it's only pressing "space".
我正在尝试使用Python自动发送一条消息到Roblox,它能够输入消息,但无法通过按下“Enter”来发送,只有按下“Space”。
I watched a ton of videos on how to get it to press enter and I also tried different keys to see which one would be enter but nothing worked.
我观看了大量关于如何让它按Enter键的视频,并尝试了不同的键来确定哪个是Enter键,但都没有成功。
I'm trying to get it so send a randomized message from a list every 1 - 2 minutes. Here's my code:
我希望它每隔1到2分钟从列表中发送一条随机消息。以下是我的代码:
import pyautogui
import time
time.sleep(5)
pyautogui.write("/Test", interval = 0.1)
pyautogui.press('enter')
英文:
I'm trying to get python to automate sending a message in Roblox and it's typing out the message, but it's not sending it by pressing "enter", it's only pressing "space".
I watched a ton of videos on how to get it to press enter and I also tried different keys to see which one would be enter but nothing worked. I'm trying to get it so send a randomized message from a list every 1 - 2 minutes. Here's my code:
import pyautogui
import time
time.sleep(5)
pyautogui.write("/Test", interval = 0.1)
pyautogui.press('enter')
答案1
得分: 0
import pyautogui
import time
import random
messages = ["Hello!", "How are you?", "Nice to meet you!"]
time.sleep(5)
while True:
message = random.choice(messages)
pyautogui.typewrite(message, interval=0.1)
pyautogui.press('enter')
time.sleep(random.uniform(60, 120))
英文:
Try this in your IDE, than if it works try it inside Roblox.
import pyautogui
import time
import random
messages = ["Hello!", "How are you?", "Nice to meet you!"]
time.sleep(5)
while True:
message = random.choice(messages)
pyautogui.typewrite(message, interval=0.1)
pyautogui.press('enter')
time.sleep(random.uniform(60, 120))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论