pynput does not press key correct

Viewed 75

I want to press the Persian characters with the keyboard in python, I tried some libraries, most of them couldn't work with the Persian character at all, then I found pynput, it worked but couldn't press several keys correctly ...

do you have any solution?

This is the code:

import time
from pynput.keyboard import Controller
controller = Controller()

fa = ['ا', 'ب', 'پ', 'ت', 'ث', 'ج', 'چ', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'ژ', 'س', 'ش', 'ص', 'ض', 
      'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ک', 'گ', 'ل', 'م', 'ن', 'و', 'ه', 'ی']

def type_words():
    for c in fa:
        controller.type(c)
        time.sleep(.1)
        print('  --->  ', c)


type_words()

and This is the output:

ا  --->   ا
ب  --->   ب
ب  --->   پ
ت  --->   ت
ث  --->   ث
ث  --->   ج
چ  --->   چ
ح  --->   ح
ح  --->   خ
د  --->   د
ذ  --->   ذ
ذ  --->   ر
ز  --->   ز
ژ  --->   ژ
ژ  --->   س
ش  --->   ش
ص  --->   ص
ص  --->   ض
ط  --->   ط
ظ  --->   ظ
ظ  --->   ع
غ  --->   غ
ف  --->   ف
ف  --->   ق
ک  --->   ک
گ  --->   گ
گ  --->   ل
م  --->   م
ن  --->   ن
ن  --->   و
ه  --->   ه
ی  --->   ی
0 Answers
Related