Input unicode string with pyautogui

I know this thread is old, but for the sake of the topic I managed to get around it using pyperclip in an easier manner in my opinion.

Rather than trying to make pyautogui to type special characters, copy them to the clipboard using pyperclip and then use pyautogui to paste them. For instance on Windows:

import pyautogui
import pyperclip

pyperclip.copy("It's leviOsa, not lêvioçÁ!")
pyautogui.hotkey("ctrl", "v")

EDIT:

We can make it work in multiple platforms as below (thanks @karlo for pointing it out):

import pyautogui
import pyperclip
import platform

def type(text: str):    
    pyperclip.copy(text)
    if platform.system() == "Darwin":
        pyautogui.hotkey("command", "v")
    else:
        pyautogui.hotkey("ctrl", "v")


type("It's leviOsa, not lêvioçÁ!")

Leave a Comment