/PyCurrentWindow

A python program meant to send the current window to my Adafruit Macropad

Primary LanguagePythonMIT LicenseMIT

PyCurrentWindow

made-with-python license-mit latest-version made-for-windows

A python-based program that links with a CircuitPython board via serial, and reports the currently running program to it.

📖 Background

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

💭 So what exactly does it do?

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).

⬇️ Installation and Usage

On any computer you wish to use the MacroPad with...

See the latest release

On your CircuitPython Macropad

You have two options:

  1. Copy and paste the following code.py here into your CIRCUITPY 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)
  1. 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

⚠️ Issues

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!

🔧 Development

  1. Clone the repo onto your computer
  2. Navigate to the cloned repo
  3. Create and activate a virtual enviroment
  4. Run pip install -r requirements.txt
  5. Happy Developing!

Contributing

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.