An Interest In:
Web News this Week
- March 14, 2024
- March 13, 2024
- March 12, 2024
- March 11, 2024
- March 10, 2024
- March 9, 2024
- March 8, 2024
Automating MS Teams
Disclaimer:
This code is for educational purposes only and the author is not responsible for any consequences resulted. Please do not try it if you do not agree for the condition.
Hello everyone,
In this post I will be showing how I have automated MS Teams.
Most of us are aware that Teams is a video conferencing app which allows us to attend/conduct meetings. And because of this pandemic situation, the usage of these video conferencing apps also increased and most of the classes and lectures and conferences are conducted in Teams now a days.
Let us see how I have automated Teams so that it automatically logs into one's meetings/classes on time.
Pre-requisites:
- Microsoft Teams application - Download the exe file from here
- Python
- Pyautogui
Pyautogui :
PyAutoGUI is a cross-platform GUI automation Python module. It programmatically controls the mouse & keyboard. It has screen shot features and also image finding features.
pip install pyautogui
Working :
- An infinite loop keeps checking the current time of the system using
datetime.now()
funtion. - The Teams app is opened using
os.startfile()
. pyautogui.locateCenterOnScreen()
function locates the center of the first found instance of the image on the screen.pyautogui.moveTo()
moves the cursor to that location.pyautogui.click()
performs a click operation.
Note :
Before using the script make sure that the Teams application is closed in such a way that all the teams are displayed as shown in the below figure.
Import the necessary modules
import os import pyautoguiimport timefrom time import sleepfrom datetime import datetime
Open Teams
os.startfile("C:/Users/username/AppData/Local/Microsoft/Teams/current/Teams.exe")
Next, take the screenshot of settings button and use the below chunk of code to move the mouse to that button and click it.
settings = pyautogui.locateCenterOnScreen("settings.PNG") pyautogui.moveTo(settings)pyautogui.click()time.sleep(2)
Now we need to click on Manage Teams button to get a list of teams vertically.
manageteams = pyautogui.locateCenterOnScreen("manageteams.PNG") pyautogui.moveTo(manageteams)pyautogui.click()time.sleep(2)
then we will get the screen like this
Now we run the below code snippet in an infintie loop.
We get the current time and compare it with the class ending time . For example if current time is 17:00 and my class is at 17:00 but the meeting has started. If I give my class ending time i.e 18:00 then as soon as meeting starts the scripts automatically clicks on join button with camera and microphone turned off.
- Join button is given below.
- Camera and microphone button is given below.
- Similarily take the screenshot of your class name too.
if now < '18:00': Andromeda =pyautogui.locateCenterOnScreen("Andromeda.PNG") pyautogui.moveTo(Andromeda) pyautogui.click() time.sleep(2) join = pyautogui.locateCenterOnScreen("join.PNG") pyautogui.moveTo(join) pyautogui.click() time.sleep(2) audiooff = pyautogui.locateCenterOnScreen("audiooff.PNG") pyautogui.moveTo(audiooff) pyautogui.click() time.sleep(2)
Similarily you can do it for n number of classes.
In the below code I have done it for 2 classes.
import os import pyautoguiimport timefrom time import sleepfrom datetime import datetimetry: # open MS Teams application os.startfile("C:/Users/username/AppData/Local/Microsoft/Teams/current/Teams.exe") sleep(2) # settings settings = pyautogui.locateCenterOnScreen("settings.PNG") pyautogui.moveTo(settings) pyautogui.click() time.sleep(2) # manageteams.PNG manageteams = pyautogui.locateCenterOnScreen("manageteams.PNG") pyautogui.moveTo(manageteams) pyautogui.click() time.sleep(2)except Exception as e: print(e)while True: #andromeda now = datetime.now().strftime("%H:%M") if now < '18:00': Andromeda = pyautogui.locateCenterOnScreen("Andromeda.PNG") pyautogui.moveTo(Andromeda) pyautogui.click() time.sleep(2) join = pyautogui.locateCenterOnScreen("join.PNG") pyautogui.moveTo(join) pyautogui.click() time.sleep(2) audiooff = pyautogui.locateCenterOnScreen("audiooff.PNG") pyautogui.moveTo(audiooff) pyautogui.click() time.sleep(2) elif now <'17:00': Automation = pyautogui.locateCenterOnScreen("Automation.PNG") pyautogui.moveTo(Automation) pyautogui.click() time.sleep(2) join = pyautogui.locateCenterOnScreen("join.PNG") pyautogui.moveTo(join) pyautogui.click() time.sleep(2) audiooff = pyautogui.locateCenterOnScreen("audiooff.PNG") pyautogui.moveTo(audiooff) pyautogui.click() time.sleep(2)
I have uploaded the entire code and all the required files in my repository. Please drop a star if you like it.
Original Link: https://dev.to/chitturiarunkrishna/automating-ms-teams-43n6
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To