Giter VIP home page Giter VIP logo

Comments (6)

moses-palmer avatar moses-palmer commented on July 20, 2024

from pynput.

masoudr avatar masoudr commented on July 20, 2024

Windows

from pynput.

moses-palmer avatar moses-palmer commented on July 20, 2024

I have attempted to reproduce the error. My default keyboard layout is Swedish; for the purpose of troubleshooting, I installed Arabic (Iraq).

I used the following simple test program:

from pynput import keyboard

def on_press(key):
    if key == keyboard.Key.esc:
        listener.stop()
    else:
        print(ord(getattr(key, 'char', '0')))

controller = keyboard.Controller()
with keyboard.Listener(
        on_press=on_press) as listener:
    listener.join()

Starting the program with my default keyboard layout, I verified that the characters were registered correctly, and then I switched keyboard layouts. The new layout keys were registered as expected.

Please note that there is one caveat: pynput uses the keyboard layout of the current foreground thread, which is the owner of the active window. If this window belongs to cmd.exe, the layout reported does not correspond to the system layout for some reason. Can you please verify that the issue persists if you select another window?

from pynput.

masoudr avatar masoudr commented on July 20, 2024

You are right about that.
I tried to write the output of the program to a text file, If I focus on cmd (console window) it can't detect the current language and always show the old one, but If change my focus window to another like desktop it works fine. Anyway, I don't want the console itself and I want to detect the keystrokes on any window.
Thanks.

from pynput.

unistudyper avatar unistudyper commented on July 20, 2024

hi can you advice more in this regard still no luck in detecting another language when changed

from pynput.

masoudr avatar masoudr commented on July 20, 2024

@unistudyper If I remember correctly I had a problem with the latest version, try to use older versions and check out the above examples. It should work fine on Unicode chars.

from pynput.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.