How can I write a variable in python on the computer? I want to paste a text and I can't use pyautogui because the text is in Hebrew. this is my code:
from pynput.keyboard import Key, Listener
import pyautogui as pya
import pyperclip
def copy_clipboard():
pya.hotkey('ctrl', 'c')
return pyperclip.paste()
def changeLanguge(text):
finelText = ""
data = {
't': 'א',
'c': 'ב',
'd': 'ג',
's': 'ד',
'v': 'ה',
'u': 'ו',
'z': 'ז',
'j': 'ח',
'y': 'ט',
'h': 'י',
'f': 'כ',
'k': 'ל',
'n': 'מ',
'b': 'נ',
'x': 'ס',
'g': 'ע',
'p': 'פ',
'e': 'ק',
'm': 'צ',
'r': 'ר',
'a': 'ש',
',': 'ת',
'w': "'",
'q': '/',
'i': 'ן',
'o': 'ם',
';': 'ף',
'l': 'ך',
'.': 'ץ',
'/': '.',
}
for char in text:
if char in data:
finelText += data[char]
else:
finelText += char
return finelText
def on_press(key):
if str(key) == 'Key.f9':
var = copy_clipboard()
changeLanguge(var)
pya.typewrite(changeLanguge(var)) #here i want to paste the text
with Listener(on_press=on_press) as listener:
listener.join()
The purpose of the program is to convert text from English into Hebrew when f9 is pressed. the converting of the text works but I can't paste thetext into the computer.