Giter VIP home page Giter VIP logo

Comments (16)

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

It appears that TISCopyCurrentKeyboardInputSource has returned NULL. Under what circumstances do you use pynput? Do you run it in a restricted context or over SSH?

from pynput.

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

Perhaps you could add some debug logging around here to check keyboard and layout?

from pynput.

Josscii avatar Josscii commented on July 2, 2024

I just use pynput on my own Mac, I try to check the layout's value here, and it turns out to be None. So I just add a Not-None Checking in your code here, it works but now keyboard can only recognize the Ctrl or alt, the normal key like a is not work.

from pynput.

Josscii avatar Josscii commented on July 2, 2024

I'm thinking that is there anything to do with the input source? I do install a third-party input source.

from pynput.

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

I think you're right. There should be a check against None return, but other than that I don't think there is much to do if the keyboard layout cannot be retrieved.

from pynput.

Josscii avatar Josscii commented on July 2, 2024

Okay, maybe it's just my mac's wired problem, I've tried it on other mac, and there's no problem to recognize the keyboard. Thanks for your help and awesome library, it helps me a lot.
And One more problem happened while I'm trying to move mouse and then click the left button, but it same that it's just too quick to do the two things at the same time, so the click event not work at times, so I have to delay some seconds to make it work, code are here:

m.position = (arr[0], arr[1])
time.sleep(1) # if i don't sleep here, the click may be not working
m.click(Button.left)
m.click(Button.left)

from pynput.

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

Could you please test fixup-mac-unknown-keyboard-layout?

I don't have access to a Mac at the moment, so I had to do some blind coding. The fixup branch is supposed to prevent the AttributeError; since the layout is unknown, you will probably still get other errors, but the goal is to get at least a numeric keycode in the end.

from pynput.

Josscii avatar Josscii commented on July 2, 2024

I'd like to do it. Should I just update pynput with pip?

from pynput.

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

You'll have to clone the repository, and then run your script with PYTHONPATH="<path to repo>/lib" python .... Make sure to have the branch fixup-mac-unknown-keyboard-layout checked out.

from pynput.

Josscii avatar Josscii commented on July 2, 2024

image
is this line that you modified? I think I can just change to same code as your fix, if it works, I will post here to tell you.

from pynput.

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

That is correct.

from pynput.

Josscii avatar Josscii commented on July 2, 2024

image
It seems that it has a syntax error.
image

from pynput.

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

Perhaps you could copy darwin.py from here and replace your local copy?

from pynput.

Josscii avatar Josscii commented on July 2, 2024

image
new bugs....

from pynput.

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

Hmm, these line numbers do not match the latest master. Do you think that you could run it from the repository?

from pynput.

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

I have released pynput 1.3 which fixes this issue.

The fix prevents the crash, but some functionality may not be available.

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.