U
U
userpyy2020-06-10 12:51:46
Python
userpyy, 2020-06-10 12:51:46

How to print Russian characters?

I tried to print via pyautogui but alas it only supports english letters.

import pyautogui
pyautogui.write("Привет")


But I still can’t write the text, I tried to change the layout (Hi - Ghbdtn) but it doesn’t work very stable, for example, if you run the script with the Russian layout, it won’t write at all, for this you need to turn on the English layout at startup and after starting do pause and switch to Russian, it's not convenient.

I searched the internet and couldn't find anything.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
userpyy, 2020-06-10
@userpyy

import pyperclip, keyboard, time

def paste(text: str):    
    buffer = pyperclip.paste()
    pyperclip.copy(text)
    keyboard.press_and_release('ctrl + v')
    pyperclip.copy(buffer)


def type(text: str, interval=0.0):    
    if interval == 0.0:
        paste(text)
        return

    buffer = pyperclip.paste()
    for char in text:
        pyperclip.copy(char)
        keyboard.press_and_release('ctrl + v')
        time.sleep(interval)
    pyperclip.copy(buffer)

type('Привет мир!', 0.1)

L
leham1, 2020-06-10
@leham1

I am using pywinauto. Russian letters are supported there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question