armccoy / macropad-rp2040-hotkeys

A collection of hotkey macros for the Adafruit Macropad RP2040
26 stars 6 forks source link

Bind a string of text to key? #1

Closed aptonline closed 2 years ago

aptonline commented 2 years ago

It is possible to bind a string to a key using the macros?

Use case would be for launching an app for example, command + space opens the Spotlight Search (Mac) and then I need to ''send' the application name (via the string) and then send a return to launch.

Maybe I'm missing something but in the macropod docs I did find the following but can't find a way to implement with your hotkeys:

macropad.keyboard_layout.write("Hello, World!")

Many thanks.

aptonline commented 2 years ago

Ok I think I have worked it out:

  (0x540908, 'Launch Twitter', [Keycode.COMMAND, Keycode.SPACE," Twitter",Keycode.RETURN]),

Had to add a space at the begining of the text to send otherwise it would truncate the first letter. Can't get the above to send the return key either.

aptonline commented 2 years ago

And worked it out by adding \n at the end of the string to search for :)

(0x540908, 'Launch Twitter', [Keycode.COMMAND, Keycode.SPACE," Twitter\n"]),

armccoy commented 2 years ago

Try using Keycode.ENTER to send the return key command. That's what I used in macros/numpad.py.

And I really like your idea of using it for an app launcher! Thanks!