Hey I've only really started Python and I decided to make program that catches certain keys, I found source online that captures mouseclicks and decided to start off with that, this is the code:
import Xlib
import Xlib.display
display = Xlib.display.Display(':0')
root = display.screen().root
root.change_attributes(event_mask = Xlib.X.ButtonPressMask | Xlib.X.ButtonReleaseMask)
while True:
event = root.display.next_event()
print "hi"
This is the error get when I run it:
miles@miles:~/py/keynotify$ python x.py
Xlib.protocol.request.QueryExtension
X protocol error:
<class 'Xlib.error.BadAccess'>: code = 10, resource_id = 173, sequence_number = 9, major_opcode = 2, minor_opcode = 0
^CTraceback (most recent call last):
File "x.py", line 9, in <module>
event = root.display.next_event()
File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 171, in next_event
self.send_and_recv(event = 1)
File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 502, in send_and_recv
rs, ws, es = select.select([self.socket], writeset, [], timeout)
KeyboardInterrupt
Would really appreciate any help!