A python-based program that links with a CircuitPython board via serial, and reports the currently running program to it.
I recently purchased the Adafruit MacroPad RP2040. I plan on using this nifty little thing, as... a Macropad.
To do this, I have utilized the guide on Adafruit called MACROPAD Hotkeys. This is a great starting point, but I want MORE.
I want my MacroPad to be able to switch macro sets automatically. As mentioned in the guide...
Could there be some way to automatically switch based on the current application in use? CircuitPython can receive serial messages while also emulating a keyboard, so there’s ways to send information to MACROPAD. The host-side implementation though, that gets complex, and would vary with all the myriad system types and their particular scripting or development options, which is why it’s not done here. Food for thought!
Food for thought indeed... Which is what has driven me to create PyCurrentWindow
I'm so glad you asked. Well, for the Macropad to be able to switch macro profiles automatically, it would have to know which program was currently in focus.
As mentioned in the guide excerpt from earlier:
CircuitPython can receive serial messages while also emulating a keyboard
So, PyCurrentWindow, naturally, is designed to run quietly in the background, and send the current program name (i.e. firefox.exe
) to the MacroPad via serial (COM).
See the latest release
You have two options:
- Copy and paste the following
code.py
here into yourCIRCUITPY
drive.
- Once running, you can modify any of the existing Macro files by adding a dictionary key
program
. Set the value to the program name you'd like to use with those Macro keys. - The
program
key and value are NOT required! Existing macros still work! - Even if the Macropad switches automatically, you can still manually cycle through the profiles. (Note that if a bound program window refocuses, it will switch back to that macro)
- Modify your
code.py
yourself.
- PyCurrentWindow will send
"IDENTIFY"
over serial to any USB devices. - Your MacroPad needs to recieve this message, and respond back
"ADAFRUIT MACROPAD"
. - Additionally, you will need to listen for messages telling the MacroPad which program is running
This app is in the early stages of it's development. Please let me know if you encounter any errors, or if there's any functionality you'd like to see implemented!
- Clone the repo onto your computer
- Navigate to the cloned repo
- Create and activate a virtual enviroment
- Run
pip install -r requirements.txt
- Happy Developing!
I don't expect this repo to get much attention, nor do I have much expertise in running repos, but if you would like to contribute to this project, feel free to open a PR.