This write-up explains step by step how to reproduce the same button.
Follow me on Twitter: @mondalan
IntroductionAfter each Zoom meeting ended, I often found myself awkwardly hunting for the Leave Meeting button. It always seems to vanish. After I was done with this project, I also realized that hitting that button is extremely gratifying. Like hanging up an old school phone receiver.
First ApproachI initially thought about using JWT (Jason Web Token) and leverage Zoom's API. That wouldn't work for this project because Zoom's API doesn't have a RESTful query InstantMeetings. It can only list scheduled meetings. It would be pretty limited. So I scratched that idea.
Think Outside the APIInstead of using a complicated API with authorization tokens, etc, I've leveraged Particle Photon's USB HID (Hardware Input Device) capability! That's right, you can turn your Particle Photon into a typing bot. All I needed for the Photon to be able to send three key-strokes:
- The left ALT key
- The Q key
- The Enter key
Here's the part of the code that checks the button state and sends the key presses (keep scrolling to find the full repository at the end):
void check_state_and_send_shortcut() {
if (is_button_pressed && !keystroke_sent){
// sending Alt + q shortcut
Keyboard.press(KEY_LALT);
Keyboard.press(KEY_Q);
Keyboard.releaseAll();
// press and release enter key to confirm we want to exit
Keyboard.click(KEY_ENTER);
keystroke_sent = true;
}
}
WiringWiring for this project couldn't be simpler. I connected the 3V3 pin on the Particle Photon to the normally open side of the switch, and the A0 pin to the common. The advantage of this project is that the micro-usb cable provides power and sends the key stroke.
Full Code:
/*
* Project End Zoom Meetings Button
* Description: Smash the button to end your zoom meetings
* Author: Alan Mond
* Date: 21 December 2020
* License: GNU GPLv3
*/
int raw_value = 0;
bool is_button_pressed = false;
bool keystroke_sent = false;
SerialLogHandler logHandler;
SYSTEM_THREAD(ENABLED);
// Initialize device as a Hardware Input Device (basically a keyboard)
STARTUP(Keyboard.begin());
void check_state_and_send_shortcut(){
if (is_button_pressed && !keystroke_sent){
// sending Alt + q shortcut
Keyboard.press(KEY_LALT);
Keyboard.press(KEY_Q);
Keyboard.releaseAll();
// press and release enter key to confirm we want to exit
Keyboard.click(KEY_ENTER);
keystroke_sent = true;
}
}
void loop() {
raw_value = analogRead(A0);
if ( raw_value > 2500 ) {
is_button_pressed = true;
}
else {
is_button_pressed = false;
keystroke_sent = false;
}
check_state_and_send_shortcut();
}
Comments