November 29, 2021

Teams Shortcuts: Personalize Mention fix for flat chats

I have stumbled upon an issue in the Microsoft Teams Client for the Mention Personalizing feature in the Teams Shortcuts PowerTool. This issue occurs only in Flat Standalone Chats (not in Teams Channels).
I share it here and propose a workaround.

Issue description

(as of now 2021-11-29) When you select a mention part in a Teams flat chat (group or 1-1 chat*/ not in a Channel) and copy it to the clipboard with Ctrl+C you will get some weird stuff like null if something is selected and the zero-width space character (Ascii code 8203) if nothing is selected.

This is totally inconsistent/orthogonal to the behavior in Channel Chats. [But this inconsistency is to be expected somehow as standalone/group chats behave from the core differently than Channel chats (e.g. you can provide a subject/ have threaded conversations in channel chats and all is flat in standalone/group chats.)]

Workaround

Because of this behavior (return null on selection), it is impossible to handle different mentions formats in a robust way like for the Channel chats. So you can not handle if the names are displayed with the company name or if there is a - in the name or a space in the company name etc.

For my company I have hard-coded to support this format Surname, Lastname (Company Name) i.e. with a single space in the company name. 

At least it will work for my direct colleagues.

This two lines of code in ahk/Lib/Teams.ahk->(function) Teams_PersonalizeMention implement this workaround:

sLastLetter := Clip_GetSelection()  
SendInput {Right}

; remove (company)
If (Asc(sLastLetter) = 8203) { ; standalone chat returns zero-width space - get selection does not work (return null)
    SendInput {Ctrl down}{Backspace}{Backspace}{Left}{Backspace}{Right}{Ctrl up}
    return

In case you have another mention name pattern in your company feel free to adjust this line of code.

* Of course mentioning in a 1-1 chat isn't very useful ;-)

No comments:

Post a Comment