0

AdaBox 019 Macropad: Zoom hotkey code (Mac)!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by blakbuzzrd on Wed Jul 28, 2021 12:26 pm

So after eagerly assembling my Macropad from Adabox 019 last night, I read Phillip Burgess's hotkey guide at http://https://learn.adafruit.com/macropad-hotkeys. He suggests that we might share custom configuration files here in the forums. I searched but I didn't find any; so here's one I made for Zoom on Mac. Hope it’s useful to you!

NOTE: I put the "don't-wanna-accidentally-hit-this" keys away from the edges where possible, and color-coded things by general type. Audio keys are red, informational keys are yellow, video keys are blue, and window resizing etc. keys are white. Also, the second key in the first row is not commented, because of line length limitations; that key controls visibility of the floating control bar in Zoom.

Apologies if I screwed up something in this post. I just turned 50 last week, and this is the first time I've really tried to make something like this that runs on code. Learning is fun!

Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Zoom for Mac

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    "name": "Mac Zoom",  # Application name
    "macros": [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x800000, "Space", ["SPACE"]),  # Temporarily Unmute
        (0x202000, "Control", [Keycode.CONTROL, Keycode.OPTION, Keycode.COMMAND, "H"]),
        (0x800000, "Mute", [Keycode.COMMAND, Keycode.SHIFT, "A"]),  # Mute/Unmute Audio
        # 2nd row ----------
        (0x004000, "Video", [Keycode.SHIFT, Keycode.COMMAND, "V"]),  # Start/Stop Video
        (0x004000, "Camera", [Keycode.SHIFT, Keycode.COMMAND, "N"]),  # Switch Camera
        (0x004000, "Share", [Keycode.SHIFT, Keycode.COMMAND, "S"]),  # Screen Sharing
        # 3rd row ----------
        (0x202000, "ID", [Keycode.COMMAND, "2"]),  # Read Active Speaker Name
        (0x800000, "Record", [Keycode.SHIFT, Keycode.COMMAND, "R"]),  # Local Record
        (0x202000, "Capture", [Keycode.COMMAND, "T"]),  # Chat Screenshot
        # 4th row ----------
        (0x101010, "FullSc", [Keycode.SHIFT, Keycode.COMMAND, "F"]),  # Full Screen
        (0x101010, "MinWin", [Keycode.SHIFT, Keycode.COMMAND, "M"]),  # Minimal
        (0x101010, "Gallery", [Keycode.SHIFT, Keycode.COMMAND, "W"]),  # View
        # Encoder button ---
        (0x000000, "", [Keycode.COMMAND, "W"]),  # Close Current Window
    ],
}

blakbuzzrd
 
Posts: 8
Joined: Tue Feb 09, 2021 10:12 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by adafruit_support_carter on Wed Jul 28, 2021 3:29 pm

Awesome. Thanks for sharing!

adafruit_support_carter
 
Posts: 21106
Joined: Tue Nov 29, 2016 2:45 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by blakbuzzrd on Wed Jul 28, 2021 3:48 pm

So after some field testing on several client calls today, I discovered several things:
1. The "Temporarily Unmute" keymapping isn't functioning as desired. Working to fix that.
2. The Chat "Capture" function is a dumb waste of a key. Remapping!
3. The "ID" key also doesn't seem to do anything. Investigating.

blakbuzzrd
 
Posts: 8
Joined: Tue Feb 09, 2021 10:12 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by adafruit_support_carter on Wed Jul 28, 2021 5:52 pm

No worries. Can just post the updated versions here :)

adafruit_support_carter
 
Posts: 21106
Joined: Tue Nov 29, 2016 2:45 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by LarryGB on Wed Jul 28, 2021 11:03 pm

I would like to see a version for Win if possible. Or what would need to be changed in your config to accommodate MS PC? Would be happy to try to make one but not sure of the extra parameters are required/

LarryGB
 
Posts: 2
Joined: Wed Jul 28, 2021 11:01 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by LarryGB on Thu Jul 29, 2021 1:47 am

My attempt at a Win version, what else do I need?


Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Zoom for WIN - LGB Jul 28 2021

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    'name': 'Zoom for WIN',  # Application name
    'macros': [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x800000, "-Space", ['SPACE']),  # Temporarily Unmute
        (0x202000, "Invite", [Keycode.ALT, "i"]), #Invitation
        (0x800000, "Mute", [Keycode.ALT, "a"]),  # Mute/Unmute Audio
        # 2nd row ----------
        (0x004000, 'Video', [Keycode.ALT, 'v']),  # Start/Stop Video
        (0x004000, 'Camera', [Keycode.ALT, "n"]),  # Switch Camera
        (0x004000, "Share", [Keycode.ALT, "s"]),  # Screen Sharing
        # 3rd row ----------
        (0x202000, "-ID", [Keycode.ALT, "2"]),  # Read Active Speaker Name
        (0x800000, "Record", [Keycode.ALT, "r"]),  # Local Record
        (0x202000, "Chat", [Keycode.ALT, "h"]),  # Chat Screenshot
        # 4th row ----------
        (0x101010, "FullSc", [Keycode.ALT, "f"]),  # Full Screen
        (0x101010, "-MinWin", [Keycode.ALT, "w"]),  # Minimal
        (0x101010, "Gallery", [Keycode.ALT, "w"]),  # View
        # Encoder button ---
        (0x000000, "", [Keycode.ALT, "w"]),  # Close Current Window
    ],
}


% working.

LarryGB
 
Posts: 2
Joined: Wed Jul 28, 2021 11:01 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by adafruit_support_carter on Thu Jul 29, 2021 2:53 pm

Another way to share these is submit a Pull Request to have them added to the Guide code. Here's an example:
https://github.com/adafruit/Adafruit_Le ... /pull/1664

But this approach does require having a Github account and knowing the general process for making Pull Request. So just sharing here in the forums is fine as well. It's pretty easy to just grab the code from here.

adafruit_support_carter
 
Posts: 21106
Joined: Tue Nov 29, 2016 2:45 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by blakbuzzrd on Sat Jul 31, 2021 10:58 am

So I've been digging a couple days, trying to figure out a single problem:

I can't figure out how to tell the Macropad what to do when a key is pressed and held. So, for example, in Zoom, you can temporarily unmute the mic by holding down the spacebar. In Chrome, you can hold down the spacebar and the screen will scroll.

My search on this so far has been futile, but I am a complete beginner, and just starting to wrap my brain around coding.

I suspect the answer lies implicit somewhere in the Macropad Tone guide, in the discussion of key events: https://learn.adafruit.com/adafruit-macropad-rp2040/macropad-tone

If I'm missing an obvious resource, please feel free to say so.

Any tips?
Last edited by blakbuzzrd on Sat Jul 31, 2021 11:06 am, edited 1 time in total.

blakbuzzrd
 
Posts: 8
Joined: Tue Feb 09, 2021 10:12 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by blakbuzzrd on Sat Jul 31, 2021 11:00 am

adafruit_support_carter wrote:Another way to share these is submit a Pull Request to have them added to the Guide code. Here's an example:
https://github.com/adafruit/Adafruit_Le ... /pull/1664

But this approach does require having a Github account and knowing the general process for making Pull Request.

I will learn how to do this, and start doing it. Thanks!

blakbuzzrd
 
Posts: 8
Joined: Tue Feb 09, 2021 10:12 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by adafruit_support_carter on Sat Jul 31, 2021 12:44 pm

Each key press generates two messages, one for when the key is initially pressed down and one for when the key is finally released. For the majority of cases, like with normal typing, these two messages happen in rapid succession. A "held" key would be one where the "pressed" message is sent, but not the "released" message (until sometime later). So it's just a matter of code, but maybe somewhat complex code, to watch for that pattern. Like have a timer that is zeroed when a key is "pressed" and then if a "released" message does not show up after a set period of time, then take the "key held" action. That's the general idea at least.

adafruit_support_carter
 
Posts: 21106
Joined: Tue Nov 29, 2016 2:45 pm

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by demsecure on Mon Aug 09, 2021 1:22 pm

LarryGB wrote:I would like to see a version for Win if possible. Or what would need to be changed in your config to accommodate MS PC? Would be happy to try to make one but not sure of the extra parameters are required/

Not sure why, but the Zoom code you posted didn't work for me. Neither did the NumPad code provided by Phil. Any key I pressed would just give me a "code done running" message and make my keyboard think the ALT key was continually pressed.

I took a swing at an alternate:
Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys example: Universal Numpad

from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values

app = {                    # REQUIRED dict, must be named 'app'
    'name' : 'Zoom', # Application name
    'macros' : [           # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x0000FF, 'Mute', [Keycode.ALT, Keycode.A]),
        (0x0000FF, '', [Keycode.I]),
        (0x0000FF, '', [Keycode.ALT,]),
        # 2nd row ----------
        (0x0000FF, 'Video', [Keycode.ALT, Keycode.V]),
        (0x0000FF, '', [Keycode.K]),
        (0x0000FF, 'Camera', [Keycode.ALT, Keycode.N]),
        # 3rd row ----------
        (0x0000FF, '', [Keycode.ONE]),
        (0x0000FF, '', [Keycode.TWO]),
        (0x0000FF, 'End', [Keycode.ALT, Keycode.Q]),
        # 4th row ----------
        (0x101010, '', [Keycode.CONTROL, Keycode.SHIFT, Keycode.A]),
        (0x800000, '', [Keycode.ZERO]),
        (0x101010, '', [Keycode.POUND]),
        # Encoder button ---
        (0x000000, '', [Keycode.ALT, Keycode.Q])
    ]
}


Hope this helps someone.

demsecure
 
Posts: 12
Joined: Tue Apr 19, 2016 11:19 am

Re: AdaBox 019 Macropad: Zoom hotkey code (Mac)!

by blakbuzzrd on Wed Aug 11, 2021 4:57 pm

UPDATE: I realized that my difficulty with the hotkey macros (particularly when trying to set up "Temporarily Unmute" in Zoom or "Scroll Down" in Chrome) lay in a fundamental misunderstanding of how to use the HID keycodes. After a week of banging my head against the wall, success. When I get a second, I'll do the Github thing, but meanwhile, for any Mac users, here are the latest versions of my macro configs for Zoom, Slack, Spotify (desktop app) and Chrome.

Zoom:
Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Zoom for Mac

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    "name": "Zoom",  # Application name
    "macros": [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x000000, "Mute", [Keycode.COMMAND, Keycode.SHIFT, "A"]),  # Mute/Unmute
        (0x000000, "Record", [Keycode.SHIFT, Keycode.COMMAND, "R"]),  # Local Record
        (0x000000, "TempUM", [Keycode.SPACE]),  # Temporarily Unmute
        # 2nd row ----------
        (0x000000, "Video", [Keycode.SHIFT, Keycode.COMMAND, "V"]),  # Start/Stop Video
        (0x000000, "AltCam", [Keycode.SHIFT, Keycode.COMMAND, "N"]),  # Switch Camera
        (0x000000, "Share", [Keycode.SHIFT, Keycode.COMMAND, "S"]),  # Screen Sharing
        # 3rd row ----------
        (0x000000, "FullSc", [Keycode.SHIFT, Keycode.COMMAND, "F"]),  # Full Screen
        (0x000000, "Control", [Keycode.CONTROL, Keycode.OPTION, Keycode.COMMAND, "H"]),
        (0x000000, "Gallery", [Keycode.SHIFT, Keycode.COMMAND, "W"]),  # View
        # 4th row ----------
        # Encoder button ---
        (0x000000, "", [Keycode.COMMAND, "W"]),  # Close Current Window
    ],
}

Slack (note: emoji kotkey not yet functional):
Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Slack for Mac

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    "name": "Slack",  # Application name
    "macros": [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x202000, 'Unread', [Keycode.SHIFT, Keycode.COMMAND, 'a']),  # Unreads
        (0x202000, 'Reply', [Keycode.COMMAND, 'g']),  # Search
        (0x202000, 'Emoji', 'r'),  # Emoji Reaction
        # 2nd row ----------
        (0x202000, 'New', [Keycode.COMMAND, 'n']),  # New Message
        (0x202000, 'Edit', [Keycode.COMMAND, 'e']),  # Edit Message
        (0x202000, '+File', [Keycode.COMMAND, 'u']),  # Add File
        # 3rd row ----------
        (0x202000, 'Mute', 'm'),  # Mute
        (0x202000, 'Video', 'v'),  # Video Toggle
        (0x202000, 'Invite', 'a'),  # Invite List
        # 4th row ----------
        (0x202000, 'WS1', [Keycode.COMMAND, '1']),  # 1st Workspace in List
        (0x202000, 'WS2', [Keycode.COMMAND, '2']),  # 2nd Workspace in List
        (0x202000, 'Prefs', [Keycode.COMMAND, ',']),  # Preferences
        # Encoder button ---
    ],
}

Spotify:
Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Spotify for Mac

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    "name": "Spotify",  # Application name
    "macros": [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x004000, "Play", [Keycode.SPACE]),  # Play
        (0x004000, "Back", [Keycode.COMMAND, Keycode.LEFT_ARROW]),  # Previous Track
        (0x004000, "Next", [Keycode.COMMAND, Keycode.RIGHT_ARROW]),  # Next Track
        # 2nd row ----------
        (0x004000, "Vol +", [Keycode.COMMAND, Keycode.UP_ARROW]),  # Volume Up
        (0x004000, "Vol -", [Keycode.COMMAND, Keycode.DOWN_ARROW]),  # Volume Down
        (0x004000, "Min", [Keycode.COMMAND, "m"]),  # Minimize
        # 3rd row ----------
        # 4th row ----------
        # Encoder button ---
        (0x000000, "", [Keycode.COMMAND, "w"]),  # Close Current Window
    ],
}
# Write your code here :-)

Chrome:
Code: Select all | TOGGLE FULL SIZE
# MACROPAD Hotkeys: Chrome for Mac

from adafruit_hid.keycode import Keycode  # REQUIRED if using Keycode.* values

app = {  # REQUIRED dict, must be named 'app'
    "name": "Chrome",  # Application name
    "macros": [  # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x000040, "< Back", [Keycode.COMMAND, "["]),
        (0x000040, "Reload", [Keycode.COMMAND, "R"]),
        (0x000040, "+Tab", [Keycode.COMMAND, "T"]),  # New tab
        # 2nd row ----------
        (0x000040, "Copy", [Keycode.COMMAND, "C"]),
        (0x000040, "Paste", [Keycode.COMMAND, Keycode.SHIFT, Keycode.OPTION, "V"]),
        (0x000040, "Down", [Keycode.SPACE]),  # Scroll down
        # 3rd row ----------
        (0x000040, "+Zoom", [Keycode.COMMAND, "+"]),
        (0x000040, "-Zoom", [Keycode.COMMAND, "-"]),
        (0x000040, "Incog", [Keycode.SHIFT, Keycode.COMMAND, "N"]),
        # 4th row ----------
        (
            0x000040,
            "Ada",
            [Keycode.COMMAND, "n", -Keycode.COMMAND, "www.adafruit.com\n"],
        ),  # Adafruit in new window
        (
            0x000040,
            "BGG",
            [Keycode.COMMAND, "n", -Keycode.COMMAND, "www.boardgamegeek.com\n"],
        ),  # BGG in new window
        (
            0x000040,
            "Hacks",
            [Keycode.COMMAND, "n", -Keycode.COMMAND, "www.hackaday.com\n"],
        ),  # Hack-a-Day in new win
        # Encoder button ---
        (0x000000, "", [Keycode.COMMAND, "w"]),  # Close window/tab
    ],
}

blakbuzzrd
 
Posts: 8
Joined: Tue Feb 09, 2021 10:12 pm

Please be positive and constructive with your questions and comments.