Search code examples
pythonpyautogui

how can I use persian language text in pyautogui library


I want to fill some fields using pyautogui library But the problem is that when I want to fill the fields in Persian language, it is not done How should I solve the problem of this library in the Persian language? I don't even know if the problem is with this library or with my Python because this library works well for the English language

my code:

import pyautogui
pyautogui.click(x=36, y=52)
pyautogui.write("Hello World") #This part works well
pyautogui.press('tab')
pyautogui.write("سلام دنیا")  #This part does not work

Solution

  • pyautogui library doesn't support languages except English. As recommended on this post you can use pyperclip in addition to pyautogui:

    import pyperclip
    import pyautogui
    import time
    
    pyautogui.click(x=36, y=52)
    pyautogui.write("Hello World") #This part works well
    pyautogui.press('tab')
    
    content = "سلام دنیا"
    
    pyperclip.copy(content)
    time.sleep(0.5)
    pyautogui.hotkey('ctrl', 'v')