コード例 #1
0
def starter(*args):
    global mouseListener
    global kbListener

    if not (mouseListener.running or kbListener.running):
        mqttQ.put({'topic': 'info/Living Room/lightOverride', 'payload': False})
        print('Starting on request')
        mouseListener = mListener(on_click=onActivity)
        kbListener = kListener(on_press=onActivity)
        mouseListener.start()
        kbListener.start()
        systray.update(icon=onImage)
        systray.update(hover_text='Activity Detector On')
コード例 #2
0
ファイル: main.py プロジェクト: vpramoth/Trex

def on_press(key):
    # print('{0} pressed'.format(key))
    # Modification
    length = len(record.items()) + 1
    record.update({length: [key, 1, capture()]})


def on_release(key):
    # print('{0} release'.format(key))
    if key == kKey.esc:
        # Stop listener
        return False

    # Modification
    length = len(record.items()) + 1
    record.update({length: [key, 0, capture()]})


# opening browser
# wb.open("C:\\Python27\\selenium\\chromedriver.exe")
# driver.get("http://www.trex-game.skipser.com/")
# driver.maximize_window()
wb.open("http://www.trex-game.skipser.com/")

# Collect events until released
with kListener(on_press=on_press, on_release=on_release) as listener:
    listener.join()

print record.keys()
コード例 #3
0
if __name__ == '__main__':
    # Import config
    with open('config.json') as file:
        config = json.load(file)

    # Tray icons
    onImage = './icons/activityDetectorOn.ico'
    offImage = './icons/activityDetectorOff.ico'

    # Create queue
    mqttQ = Queue()

    # Create threads
    mouseListener = mListener(on_click=onActivity)
    kbListener = kListener(on_press=onActivity)
    mqttThread = Thread(target=mqttWorker, daemon=True)

    # Create mqtt connection
    client = mqtt.Client()
    client.username_pw_set('jason')
    client.will_set('info/Living Room/lightOverride', payload=False)

    # Initialize with current time
    curTime = time()
    lastActive = [0]

    # Create system tray
    menuOptions = (('Start', None, starter), ("Stop", None, stopper),)
    systray = SysTrayIcon(onImage, 'Activity Detector On', menuOptions,
                          on_quit=onQuit)