I have a macro keyboard and I want to configure some buttons to send Mute/UnMute, Camera On/Off, Leave meeting, etc hotkeys to my running Teams Meeting window. In most cases when I am in a meeting, I am checking my emails, updating a document, so Teams is usually not the active window.
I want to do the following: my macro keyboard send Ctrl+Alt+1 and when this happens I want to send a Ctrl+Shift+M to Teams. Ctrl+Alt+1 is just an example I will use a combination which is not used in any of my usual apps.
I noticed that when I am in a call, Microsoft Teams have a main window, but the meeting opens in another window. The window title is dynamic in both, so I cannot use that. Both of them are ahk_class Chrome_WidgetWin_1, ahk_exe Teams.exe. But at least I noticed that window that I used the last responds to ahk_exe Teams.exe. So as long as I used the Meeting window last, I can switch to hat using ahk_exe Teams.exe.
So far I crated this script:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
^+1::
WinActivate, ahk_exe Teams.exe
ControlSend, , ^+M, ahk_exe Teams.exe
return
If WinActivate is the only option, is there a way of storing the current active window and switching back to my previous window after ControlSend?
[Mod edit: Topic was moved from 'Scripts and Functions'.]