英文:
Pyautogui not typing emojis
问题
我想在特定时间给朋友发送一条消息,我已经能够做到这一点,但是我需要帮助使 pyautogui 在 Instagram 网页上输入表情符号。我尝试过 pyautogui.hotkey、emoji/emojize、instabot,但它们都没有起作用。
import time
from datetime import datetime
import pyautogui
text = "Hello ❤️"
Time = input("Enter your time here:")
while(True):
present = datetime.now()
present = present.strftime("%H:%M")
if (present == Time):
pyautogui.write(text , interval=0.25)
time.sleep(5)
pyautogui.press("enter")
time.sleep(2)
break
所以,在尝试了 instabot 等之后,我无法让代码在 Instagram 网页上输入心形表情符号。
英文:
I want to send a message to a friend at a specific time, i was able to do it but, i need help in making pyautogui type emoji in the instagram web. i've tried pyautogui.hotkey, emoji/emojize, instabot, none of them worked.
import time
from datetime import datetime
import pyautogui
text = "Hello ❤️"
Time = input("Enter your time here:")
while(True):
present = datetime.now()
present = present.strftime("%H:%M")
if (present == Time):
pyautogui.write(text , interval=0.25)
time.sleep(5)
pyautogui.press("enter")
time.sleep(2)
break
So, after trying instabot and etc, i wasn't able to make the code type the heart emoji in instagram web.
答案1
得分: 0
你可以使用 Pyautogui 无法直接粘贴表情符号,首先需要将其转换为 Unicode,然后在代码中使用该值。
text = "Hello ❤️"
emoji = "2764" # 表示红心表情符号的 Unicode 值
pyautogui.hotkey('ctrl', 'shift', 'u') # 使用快捷键输入 Unicode 值
pyautogui.typewrite(emoji) # 以 Unicode 形式输入表情符号
pyautogui.press('enter')
然后在下面继续你的代码:
time.sleep(5)
pyautogui.press("enter")
time.sleep(2)
break
英文:
You can't paste an emoji directly using Pyautogui, you firstly need to convert it to unicode and then use that value in your code.
text = "Hello ❤️"
emoji = "2764" #Unicode for the red heart emoji
pyautogui.hotkey('ctrl', 'shift', 'u') #Shortcut enters unicode value
pyautogui.typewrite(emoji) #Writes the emoji in unicode
pyautogui.press('enter')
And then the rest of your code below
time.sleep(5)
pyautogui.press("enter")
time.sleep(2)
break
答案2
得分: 0
你可以尝试使用 clipboard 模块与 PyAutoGUI 结合,将所需的表情符号粘贴到文本字段中。以下是演示这种方法的更新版本代码:
import time
from datetime import datetime
import pyautogui
import clipboard
text = "Hello ❤️"
Time = input("在这里输入您的时间:")
while True:
present = datetime.now()
present = present.strftime("%H:%M")
if present == Time:
clipboard.copy(text)
pyautogui.hotkey('ctrl', 'v')
time.sleep(1)
pyautogui.press("enter")
break
英文:
You can try using the clipboard module in conjunction with PyAutoGUI to paste the desired emoji into the text field. Here's an updated version of your code that demonstrates this approach:
import time
from datetime import datetime
import pyautogui
import clipboard
text = "Hello ❤️"
Time = input("Enter your time here:")
while True:
present = datetime.now()
present = present.strftime("%H:%M")
if present == Time:
clipboard.copy(text)
pyautogui.hotkey('ctrl', 'v')
time.sleep(1)
pyautogui.press("enter")
break
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论