July 8, 2022

Shortcuts for Microsoft Teams Meeting Reactions (improved implementation based on UIAutomation)

I have shared in a previous post how to run Teams Meeting Reactions with a hotkey or command with AutoHotkey; this solution was based on ImageSearch/ FindText. I present here an improved solution based on UIAutomation.

Screencast


Challenge

One main hurdle I had to struggle with, is that the UI Elements in Teams are not always accessible.
Example if the Reactions toolbar is visible, other UI Elements like the Reactions button are not accessible.

Sometimes the Reactions Toolbar button isn't accessible by its AutomationId (reaction-menu-button).


I try to find the Reactions button by its position right to the Chat button (AutomationId=chat-button) or two buttons right to the roster(people button (AutomationId=roster-button)

If is doesn't work I try by locating the Controls Meeting Toolbar (Credit for the coding idea to Descolada)


Using UIA.ElementFromPoint makes the element accessible by its Id but returns sometimes the parent Window Element. 
So after
ReactionsEl := UIA.ElementFromPoint(BR.r+(BR.r-BR.l)//2, BR.t+20) ; Reactions button after chat
I do:   
ReactionsEl :=  TeamsEl.FindFirstBy("AutomationId=reaction-menu-button") ; Sometimes Element is made accessible by ElementFromPoint but returns only parent window element to be sure I have the right element.

Once the Reactions images are displayed, it is easy to access the single reactions by the Element name or AutomationId. Example: For Like the AutomationId is 'like-button' and the name 'Like'. For Love the AutomationId is 'heart-button' and the name is 'Love'.

Code

It is included in my AHK Teams Library - function Teams_MeetingReactions

You can also find it in this Gist:


Clicking on the Reaction will activate the Teams Meeting Window.
In the code the previously active window is restored at the end.
A tooltip is quickly displayed at the mouse position to confirm the Reaction was triggered.

The mouse position won't be changed (this is another advantage compared to the FindText previous approach.)

Usage

You can also run this from the Teams/y Launcher included with the TeamsShortcuts PowerTool.
See screencast that demonstrates how it works.


See also

Microsoft Teams: Shortcuts for Meeting Live Reactions? -> yes! (thanks to AutoHotkey)

No comments:

Post a Comment