4

I am learning pynput and working on some projects. pynput is working but it is NOT working when it comes to upper case letters or special characters like !@#$%^&** etc. but . and , are working.

Code:

 from pynput.keyboard import Key, Controller

 keyboard = Controller()

 phrase = "Hey there, smile :)"
 keyboard.type(phrase)

Output:

aey there, smile aa

As you can see it is NOT printing out upper case letters nor special characters. Instead of Hey it is doing aey

Replacing upper case letters and special characters with a

NOTE: I've tested the code with windows platform and it works perfectly fine. I'm assuming it is my Mac's fault.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
WeeeHaaa
  • 475
  • 1
  • 4
  • 10

1 Answers1

0

This is not a complete answer, but it provides you the steps to potentially use pynput on your Mac platform.

Mac OS X

Recent versions of Mac OS X restrict monitoring of the keyboard for security reasons. For that reason, one of the following must be true:

  • The process must run as root.
  • Your application must be white listed under Enable access for assistive devices. Note that this might require that you package your application, since otherwise the entire Python installation must be white listed.
  • On versions after Mojave, you may also need to whitelist your terminal application if running your script from a terminal.

Please note that this does not apply to monitoring of the mouse or trackpad.

Platform limitations for pynput

Life is complex
  • 15,374
  • 5
  • 29
  • 58