Member 14749425 Ответов: 0

Решить проблему pynput при смене языка?


Всем привет,
Я работаю над проектом на PYTHON и хочу создать кейлоггер для 2 языков-английского и греческого.
Для этого я создал приведенный ниже код.

from pynput.keyboard import Key, Listener
from langdetect import detect
from pynput import keyboard
def on_press(key):
    global string
    if key == keyboard.Key.esc: #if button escape is pressed close the program
        listener.stop()
    elif key == keyboard.Key.space:
        print(string)
        string=""
    else:
        string = ''.join([string,str(key).replace("'","")])
string=""
controller = keyboard.Controller()
# Collect events until released
listener = keyboard.Listener(on_press=on_press)
listener.start()


Что я уже пробовал:

I run it and all good until I change the language.
The problem that I am facing is explained below.
If I start typing in english, the printed result is in english but when I change in greek the printed result remains english.
If I start typing in greek the printed result is in greek, but when I change in english the result remains greek.
<a href="https://ibb.co/qC9GK8x"></a>
<a href="https://ibb.co/Z6Y0Lzp"></a>

How can I solve this problem in order to take the same language result after an input language change?
Any help or advice would be great!
Thanks in advance.

0 Ответов