July 1, 2022

Using UI Automation AHK Library to Control Microsoft Teams

I have recently learned (thanks to Joe and Isaias) about another way of automating programs with AutoHotkey based on the UI Automation API.
I give it a try here with Microsoft Teams. 
This post is a DRAFT.

Challenge

Previously I couldn't find a good way to click on buttons in Microsoft Teams: I have tried using Acc but the elements were not accessible. My last try/workaround is based on FindText but you might need to adapt the Pixeled Text to your screen to get it to work and it isn't 100% robust.

I have tried now using the UIAutomation Library and it seems you can almost dump completely the FindText approach and so access almost everything.

Setup

Download the Library from here: https://github.com/Descolada/UIAutomation

Inspect AutomationIds

Meeting Window

Inspecting the Teams Meeting Window I've found the following accessible buttons with their AutomationIds (List in Progress):

roster-button (People)
music-mode-button 
start-breakout-room-button
chat-button
video-button
microphone-button
raisehands-button (Raise)
meeting-apps-add-btn (Apps)
view-mode-button
start-breakout-room-button
share-button
callingButtons-showMoreBtn
    recording-button
    fullscreen-button
    device-settings-button
    incoming-video-button 
reaction-menu-button (React)
like-button
heart-button
applause-button
surprised-button
microphone-button
    Name: Unmute (Ctrl+Shift+M) or Mute (Ctrl+Shift+M)

Only the Reactions button does not seem easy to identify. (see section below)

Getting Meeting Window

This isn't trivial because you can not rely for UI elements to be always accessible.
See separated post here.

Getting Mute Status

You can easily do this by searching by an element with the name "Mute (Ctrl+Shift+M)"

See code below:


Challenge: Get Meeting Reactions

Because of Teams dynamically making UI Element accessible, it isn't trivial to access Meeting Reactions buttons.
See separated post here.

See also

UIAutomation with a focus on Chrome - AutoHotkey Community

Descolada/UIAutomation (GitHub)

UIA YouTube playlist (The-Automator)

No comments:

Post a Comment