Hacking the Teams Local API: How I Built a “Blind” Mute Button with AutoHotkey & Python

As a developer, few things are more frustrating than “flaky” software behavior. We’ve all been there: you’re in a Teams meeting, multitasking on another monitor, and suddenly need to cough or answer a question. You hit the global mute shortcut (Ctrl+Shift+M), but… nothing happens. Because Teams wasn’t in focus, the keystroke got swallowed by your IDE or browser.

I got tired of scrambling to find the Teams window just to toggle my microphone. I didn’t want a “hacky” solution that tries to bring the window to the front; I wanted a reliable, background-capable, state-aware toggle.

So, I built one.

The Discovery: It’s All About WebSockets

I noticed that hardware like the Elgato Stream Deck could control Teams reliably without focus. After some digging, I realized Microsoft exposes a Local Third-Party API via WebSockets on localhost:8124. This is the “proper” engineering path—don’t emulate user input; talk to the backend.

The challenge? The API requires a specific handshake and token authentication that is tricky to handle natively in simpler scripting languages.

The Stack: AHK + Python

To solve this, I combined two tools:

  1. AutoHotkey v2: The perfect tool for the “frontend.” It handles the global keyboard/mouse hooks (listening for my specific keybind) with near-zero latency.
  2. Python: The heavy lifter for the “backend.” It handles the WebSocket connection, manages the authentication token with Teams, and sends the JSON payloads.

How It Works

When I press my hotkey (mapped to a side button on my mouse), AHK triggers the Python script in the background. The script:

  1. Checks for an existing auth token.
  2. Opens a WebSocket connection to Teams.
  3. Sends the toggle-mute command.
  4. Updates the actual mute state in the Teams UI instantly.

The result is a “blind” mute button that works 100% of the time, regardless of what window I’m working in. No more “Am I muted?” anxiety.

Open Source

If you want to use this for your own setup (it’s great for macropads, foot pedals, or just a reliable F-key), I’ve open-sourced the code on GitHub. It handles the token setup automatically, so it’s pretty much plug-and-play.

Check out the repo here: https://github.com/Russell-KV4S/teams-local-mute

Let me know if you give it a try!

Tip: Use C# to Stop a Windows Service and force kill its processes on a remote computer (LAN)

I hope this tip will save someone some time as I has spent a good deal of time trying to get this to work they way I wanted. Online findings were only partial solutions to my problem.

Recently, situations cropped up where certain Windows Services were getting stuck in a “StopPending” state and would not resolve no matter how much time was given.

About a year ago I needed a way to monitor windows services in case they went down and send out email notifications so, I wrote it.

I had a UI with a SQL Server back end that would allow me to control turning off and on windows services. I also wrote a monitoring service that ran on a server that would read the table and change the flags and actually do the work of turning off an on the services based on the flags. During that project I also needed the ability to change the StartupType of the service. I wanted it to be set as Manual when it was off and Auto when it was Running.

I found a DLL on Code Project for controlling the StartupType it was simply called ServiceControllerEx.
However, it did not work for a remote computer (another computer on the LAN not on the Internet). I was able to modify the code to connect to remote computers this way:
“\\\\” + this.MachineName + “\\root\\cimv2:Win32_Service.Name='” + this.ServiceName + “‘”

After that it worked great on a remote and the local servers just fine.

Now, back to the “StopPending” problems.

I needed my monitor in some situations to not only try to stop the service but stop any processes owned by the service.

I quickly found out that using Process.Kill() only works on the local machine. If you try to use this on a remote machine it says “Feature is not supported for remote machines.”  Researching that message brought me to this blog but did not fully cover the situation I was experiencing. While this would remotely kill the processes on a remote computer it did not cover how to limit it to only processes owned by a specific service.

Note: You also needed to use this method because it allowed you to use a Service Account with the appropriate permissions to control the processes on a remote machine.

I was finally able to solve this my adding a new method to the ServiceControllerEx class that would kill a services processes like this:
KillServiceProcessesEssentially, you can use ManagementObjectSearcher to do it all.

First, define the scope which is the machine name and the service account credentials.

Second, select the ProcessID of the service.

Third, iterate through all the processes on that machine and compare the ParentProcessID to the ProcessID and call the kill command if they match.

Good luck!!
-Russell

 

Tip: Setting up a Developer Machine w/ Visual Studio 2008 and SQL Server

I ran into an issue when setting up a new machine with Visual Studio 2008 and SQL Server 2005 Developer Edition.

The Management Studio was not installed??? with some digging on the internet there is basically an issue when you install sql express before the developer editon. Express is loaded with Visual Studio.

My solution was to completly remove sql server and visual studio.

For future reference I’m going to get SQL Server installed and patched before loading Visual Studio.

I hope this helps someone in the future (including myself).

Of coarse next is to work on SQL Server 2008 and Visual Studio 2010. let’s hope that goes better!

UPDATE: I think you can also do a custom Install with VS and just not install SQL Express. I’m not going to test that right now though. 🙂

DevConnections 2009 in Orlando, FL

Tomorrow morning my family and I will be heading to Orlando so I can attend the DevConnections Developer Conference being held next week.
We are going down a few days early so we can site see and maybe go to Disney World or Sea World.
Keep an eye out I’ll probably have some pictures and maybe some video to post after we get back!

I will be posting travel/trip/conference news in real time, so if you follow me on Twitter or are a Facebook freind that’s where you’ll get the most up to date info!