# Test program for the Python client library: hotkey handling #------------------------------------------------------------------------------ import time #------------------------------------------------------------------------------ if __name__ == "__main__": from xplra import XPlane, ProtocolException xplane = XPlane() try: print "Connecting to X-Plane..." xplane.connect() print "Connected to X-Plane." print print "Registering hotkeys: Ctrl+A, Shift+B, Ctrl+Shift+C, Ctrl+Q..." xplane.registerHotkeys([0x0241, 0x0142, 0x0343, 0x0251]) print "Registered hotkeys..." print "Listening to hotkeys..." while True: states = xplane.queryHotkeys() message = "" if states[3]: break if states[0]: if message: message += ", " message += "Ctrl+A" if states[1]: if message: message += ", " message += "Shift+B" if states[2]: if message: message += ", " message += "Ctrl+Shift+C" if message: message += " pressed" xplane.showMessage(message, 3.0) time.sleep(0.5) except Exception as e: print ">>>>>>>>>>>>>>>>>>>>>> Exception caught:", str(e) finally: xplane.disconnect()