Python Forum
Solve Pynput Problem when changing language?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solve Pynput Problem when changing language?
#1
Hi everyone,
I am working on a project in PYTHON and I want to create a keylogger for 2 languages english and greek.
For this I have created the below code.

    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.
[Image: qC9GK8x]
[Image: Z6Y0Lzp]
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with "from pynput" LFreitas 1 177 Mar-24-2024, 02:23 AM
Last Post: deanhystad
  Can someone help me solve this programming problem? SuchUmami 6 887 Nov-20-2023, 10:01 AM
Last Post: EdwardMatthew
  Pynput - One content on screen, another in the variable Valjean 4 958 Sep-18-2023, 06:00 PM
Last Post: Valjean
  A simple problem, how best to solve it? SuchUmami 2 717 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,222 Jun-14-2022, 08:35 PM
Last Post: thesquid
  How do I solve the second problem? Cranberry 1 1,121 May-16-2022, 11:56 AM
Last Post: Larz60+
  Pynput Library not Working with Windows jacknewport 1 2,318 Mar-26-2022, 07:09 PM
Last Post: snippsat
  Try to solve GTG multiplication table problem. Frankduc 6 1,985 Jan-18-2022, 08:26 PM
Last Post: Frankduc
  Sudoku Solver, please help to solve a problem. AdithyaR 5 2,100 Oct-28-2021, 03:15 PM
Last Post: deanhystad
  Changing Software language in GUI Harshil 1 1,641 Oct-26-2020, 04:16 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020