SavinaRoja / PyUserInput

A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.
GNU General Public License v3.0
1.07k stars 244 forks source link

AttributeError: 'PyKeyboard' object has no attribute 'left_key' #121

Open kadanes opened 3 years ago

kadanes commented 3 years ago

I am following the readme and getting this error.

>>> from pykeyboard import PyKeyboard
>>> k = PyKeyboard()
>>> k.tap_key(k.left_key);
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'PyKeyboard' object has no attribute 'left_key'

So I tried using the x11 file because I saw that base didn't really have any definitions.

>>> from pykeyboard.x11 import PyKeyboard
>>> k = PyKeyboard()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/pykeyboard/x11.py", line 41, in __init__
    self.display = Display(display)
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/Xlib/protocol/display.py", line 84, in __init__
    name, protocol, host, displayno, screenno = connect.get_display(display)
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/Xlib/support/connect.py", line 73, in get_display
    return mod.get_display(display)
  File "/Users/Parth/opt/anaconda3/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 76, in get_display
    raise error.DisplayNameError(display)
Xlib.error.DisplayNameError: Bad display name "/private/tmp/com.apple.launchd.mzfduZgMBG/org.macosforge.xquartz:0"

Finally, I tried using mac.py. But that file does not have all the keys defined. And the ones that are defined don't work.

>>> from pykeyboard.mac import PyKeyboard
>>> k = PyKeyboard()
>>> k.tap_key('UP_ARROW_KEY');
shininome commented 1 year ago

I also encountered the same problem. Did you eventually find a solution?