March 31, 2021

AutoHotkey Tutorial: using FindText to implement shortcuts for Microsoft Teams Meeting Actions (e.g. toggle Full Screen)

I explain in this blog post including screencast, how to implement any shortcut with the AutoHotkey FindText function. Example is for Microsoft Teams and specially a Meeting Action like Toggle Full screen.

Intro

Previously I was using the AutoHotkey ImageSearch built-in function to activate by click features which where not available via a hotkey.
Now I have discovered (thanks to The-Automator) recently this FindText function, which looks more robust, faster AND does not require to share screenshot image files. 
I demonstrate here how to use FindText to implement a shortcut for the Microsoft Teams client, specially the Meeting Toggle Full Screen action.

Implementation Notes


Code extract:
Teams_Click(Id) {
If (ok := Teams_FindText(Id)) 
{
CoordMode, Mouse
X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
Click, %X%, %Y%
}
return ok

} ; eofun

; -------------------------------------------------------------------------------------------------------------------

Teams_FindText(Id:="Meeting3Dots"){
Switch Id
{
Case "Meeting3Dots","MeetingActions":
    Text:="|<>*103$26.zzzzzzzzzzzzzzzzzzzzzzzzzzyC77z1VUzkMMDyC77zzzzzzzzzzzzzzzzzzzzzzzzzzs"
Case "MeetingReactions":
    Text:="|<>*100$22.zzzzwzzz0zzk1zy07zs0TzU1zy6VztyGTby8yTltxyTnnnvjaNaS3ztzzzbzN6zwknztyTzk3zzUTzzzy"
Case "MeetingReactionHeart":
    Text:="|<>*74$26.zzzzzUT1zk307s001w000D0003U000M00060001U000Q00070003s000y000Tk00Dy007zs03zz03zzs1zzz0zzzwTzzzjzzzzzy"
Case "MeetingReactionLaugh":
    Text:="|<>*126$24.zzzzzwDzzU1zy00Tw00Ds4A7sGG7k003k003k003V00VU001U001V001l00XkU13kE03s4A7s007w00Dy00TzU1zzwDzzzzzU"
Case "MeetingReactionApplause":
    Text:="|<>*116$25.zzzzxrzzzzzrzzzzzN7zzw1vjz0Qzy06Dz01bz001zU00zk00Ds007y003z001zU00zs007y003zU01zw00zzU0zzzUzzzzzzzzzU"
Case "MeetingReactionLike":
    Text:="|<>*119$20.zzzzzwzzyDzzXzzlzzkTzsDzw3zy0zzU0zk07E01U00M006001U00M006003U00w00TzUDzzzs"
Case "MeetingActionFullScreen":
    Text:="|<>*106$93.zzzzzzzzzzzzzzzy00TzUTwbzzzzzzzjzxzwzzYzzzzzzzx7sjzbzwbzzzzzzzfzpzwwtYy3123VURTyjzbbAbnH9aNYFjzxzw4tYySTAsQbBzzjzbbAbsntU04tfzpzwwtYzmTAyTbBTyjzbmAbqH9btwtcz5zwy1Yy71C3UbBzzjzzzzzzzzzzzzk03zzzzzzzzzzzzzzzzzzzzzzzzzzzzU"
} ; eoswitch

ok:=FindText(,,,, 0, 0, Text,,0) ; last arg FindAll

return ok
} ; eofun

; -------------------------------------------------------------------------------------------------------------------
Teams_MeetingAction(id){
WinId := Teams_GetMeetingWindow()
If !WinId ; empty
    return
/*
WinGet, curWinId, ID, A
MouseGetPos , MouseX, MouseY
*/
WinActivate, ahk_id %WinId%

WinGetPos , , ,WinWidth, WinHeight, A

ok := Teams_Click("MeetingActions")
If !(ok) {
    TrayTip Teams Meeting Action: ERROR, FindText failed!
    ;Run, "https://tdalon.github.io/ahk/Teams-Meeting-Reactions"
    return
}
Sleep 500
ok := Teams_Click("MeetingAction" . id)

/*
; Restore previous window and mouse position
WinActivate, ahk_id %curWinId%
MouseMove, MouseX, MouseY
*/
If (ok)
    Tooltip("Teams Meeting Reaction: " . Reaction,1000) 
}
; -------------------------------------------------------------------------------------------------------------------

References

FindText | AutoHotkey Forum

Teams Shortcuts Homepage

No comments:

Post a Comment