PyUserInput icon indicating copy to clipboard operation
PyUserInput copied to clipboard

Python3 OS X PyKeyboardEvent Crashes

Open ericmarkmartin opened this issue 9 years ago • 7 comments

I am using PyKeyboardEvent to listen for keyboard events on OS X, but Python 3 crashes when I run my instance of the subclass.

Code

>>> from pykeyboard import PyKeyboardEvent

>>> class KeyboardHandler(PyKeyboardEvent):
    def __init__(self):
        super().__init__()

    def tap(self, keycode, character, press):
        if press:
            print(character)


>>> x=KeyboardHandler()
>>> x.run()
>>> ================================ RESTART ================================

Crash Details

http://pastebin.com/6ipbyNXL

ericmarkmartin avatar Apr 21 '15 01:04 ericmarkmartin

Sweet mother of... Could you move the crash details into a pastebin or other storage, instead of making us scroll a marathon? Just keeping things tidy.

edwanvi avatar May 15 '15 20:05 edwanvi

I wonder if this is a Quartz/CG problem.. IMHO pyUserInput needs a total rethink around OS X.. re: https://github.com/SavinaRoja/PyUserInput/issues/45#issuecomment-45683670

willwade avatar Jun 15 '15 21:06 willwade

Hi, i have the same problem with python 2.7, my code is similar:

from pykeyboard import PyKeyboardEvent

class EventKeyboard(PyKeyboardEvent):
    def __init__(self):
       PyKeyboardEvent.__init__(self)

    def tap(self, keycode, character, press):
        if press:
            print character

event=EventKeyboard()
event.run()

if i run this: "Segmentation fault: 11"

7i11 avatar Jul 24 '15 13:07 7i11

same issue on python2.7 osx el capitan using the same example as @7i11

WnP avatar Dec 28 '15 12:12 WnP

IIRC, the PyKeyboardEvent API is rather unfinished. I am still rethinking pykeyboard in general because it does not do localization/internationalization right.

SavinaRoja avatar Dec 28 '15 12:12 SavinaRoja

@SavinaRoja thanks for caring about localization/internationalization stuff, this will be realy usefull in the future

nevertheless, to fix the segfault issue on osx you/we need to allow the app to control the computer in:

System Preferences > Security & Privacy > Accessibility

add your application -in my case for developement purpose iTerm- in the list and you're done ;-)

WnP avatar Dec 28 '15 14:12 WnP

Maybe some inspiration could be taken from https://github.com/moses-palmer/pynput

I guess we should document the accessibility settings for Mac installation instructions?

pepijndevos avatar Jan 02 '16 09:01 pepijndevos