PyAutoGui没有按下”enter”。

huangapple go评论59阅读模式
英文:

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))

huangapple
  • 本文由 发表于 2023年4月4日 18:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75928189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定