示例#1
0
def main():
    with Display.from_name() as display:
        _, xrecord_version = xrecord.query_version(display)
        print('xrecord version:', '.'.join(map(str, xrecord_version)))
        key_events = (xlib.KEY_PRESS, xlib.KEY_RELEASE)
        with xrecord.context(display, xrecord.ALL_CLIENTS,
                             device_events=key_events) as context:
            disable = disable_context_handler(context)
            signal.signal(signal.SIGINT, disable)
            signal.signal(signal.SIGTERM, disable)
            xrecord.enable_context(display, context, handle_event, None)
示例#2
0
def main():
    with Display.from_name() as display:
        _, xrecord_version = xrecord.query_version(display)
        print('xrecord version:', '.'.join(map(str, xrecord_version)))
        key_events = (xlib.KEY_PRESS, xlib.KEY_RELEASE)
        with xrecord.context(display,
                             xrecord.ALL_CLIENTS,
                             device_events=key_events) as context:
            disable = disable_context_handler(context)
            signal.signal(signal.SIGINT, disable)
            signal.signal(signal.SIGTERM, disable)
            xrecord.enable_context(display, context, handle_event, None)
示例#3
0
 def run(self):
     # create a special display connection for recording
     with Display.from_name() as recording_display:
         # record all key presses and releases, as these events indicate
         # keyboard activity
         key_events = (xlib.KEY_PRESS, xlib.KEY_RELEASE)
         with xrecord.context(recording_display, xrecord.ALL_CLIENTS,
                              device_events=key_events) as context:
             self._context = context
             # create the recording context and enable it.  This function
             # does not return until disable_context is called, which
             # happens in stop.
             xrecord.enable_context(recording_display, context,
                                    self._callback, None)