Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users
    1. Home
    2. erdnasyl
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    erdnasyl

    @erdnasyl

    0
    Reputation
    61
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    erdnasyl Unfollow Follow

    Latest posts made by erdnasyl

    • RE: Need help with python script on windows

      @emil
      Thank you for your help!
      I got a syntax error but I managed to repair it with this code:

      def got_button(bd_addr):
      	cc = fliclib.ButtonConnectionChannel(bd_addr)
      	cc.on_button_single_or_double_click = \
      		lambda channel, click_type, was_queued, time_diff: \
      			keyboard.press(Key.right) if click_type == fliclib.ClickType.ButtonSingleClick else keyboard.press(Key.left)
      	cc.on_connection_status_changed = \
      		lambda channel, connection_status, disconnect_reason: \
      			print(channel.bd_addr + " " + str(connection_status) + (" " + str(disconnect_reason) if connection_status == fliclib.ConnectionStatus.Disconnected else ""))
      	client.add_connection_channel(cc)
      

      It works perfectly and it seems I don't need to release the key.

      But it seems Windows Universal Apps don't recognize key presses sent by Python... Key presses are recognized everywhere else. Anybody knows why or how to get around it?

      The next step to have a fully functional Windows integration would be to make the script work with Eventghost. I will try either by capturing the keystroke event and by sending http requests to it's built-in webserver. I will let you know!

      posted in Developers
      erdnasyl
      erdnasyl
    • Need help with python script on windows

      Hello,
      I would like to make a simple page turner for musicians on my Microsoft Surface tablet.
      The easiest way to do that would be to emulate a Right key when pressing the Flic button once and the Left key when pressing it twice, but my programming skills are close to zero.

      So far, I've managed to run the FlicSDK.exe server and pair my Flic button using the "new_scan_wizard.py" script. Every presses are detected by the "test_client.py" script.

      I now tried to modify the test_client.py script in order to add keyboard support:

      from pynput.keyboard import Key, Controller
      keyboard = Controller()
      

      This should allow me to emulate a key press with:

      keyboard.press(Key.right)
      keyboard.release(Key.right)
      

      My test_client.py script looks like this right now:

      import fliclib
      from pynput.keyboard import Key, Controller
      
      client = fliclib.FlicClient("localhost")
      keyboard = Controller()
      
      def got_button(bd_addr):
      	cc = fliclib.ButtonConnectionChannel(bd_addr)
      	cc.on_button_up_or_down = \
      		lambda channel, click_type, was_queued, time_diff: \
      			print(channel.bd_addr + " " + str(click_type))
      	cc.on_connection_status_changed = \
      		lambda channel, connection_status, disconnect_reason: \
      			print(channel.bd_addr + " " + str(connection_status) + (" " + str(disconnect_reason) if connection_status == fliclib.ConnectionStatus.Disconnected else ""))
      	client.add_connection_channel(cc)
      
      def got_info(items):
      	print(items)
      	for bd_addr in items["bd_addr_of_verified_buttons"]:
      		got_button(bd_addr)
      
      client.get_info(got_info)
      
      client.on_new_verified_button = got_button
      
      client.handle_events()
      

      I would be very thankful if someone with Python knowledge could tell me how I can add this basic block:
      If single_press then emulate_right_key elseif double_press then emulate_left_key

      Thank you!

      posted in Developers
      erdnasyl
      erdnasyl