-
Notifications
You must be signed in to change notification settings - Fork 2
/
meetings_automation.py
137 lines (103 loc) · 4.87 KB
/
meetings_automation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import pyautogui as pag
import time
def main():
meeting_id = input("Enter Meeting ID: ")
meeting_pswd = input("Enter Meeting Password: ")
time.sleep(0.5)
go_desktop()
# success variables can contain only True or False
success_zoom = find_zoom()
if not success_zoom:
return # If find_zoom() fails, this stops the whole program
success_join_plus = find_join_plus_icon()
if not success_join_plus:
return
success_meet_id = find_join_meeting_window(meeting_id)
if not success_meet_id:
return
if meeting_pswd == "": # If a meeting does not require a password, skip the find_meeting_password_window()
return
else:
success_meeting_password = find_meeting_password_window(meeting_pswd)
if not success_meeting_password:
return
# Simulates the pressing of Windows+D to go to the Desktop
def go_desktop():
pag.hotkey("win", "d")
# In this function, we first create a variable called "zoom_icon_cord" and set it equal to None.
# We take advantage of the fact that the PyAutoGUI module is designed in such a way that if an image can't be found on the screen, it returns None.
# As long as the image (in this case, the Zoom icon) can't be found and the time elapsed is lesser than 50 sec, the while loop will keep executing and will keep searching for the image.
# But if it does find the image, the x and y values of the coordinates of the image are assigned to the zoom_icon_cord variable. Then, it double clicks on those coordinates.
def find_zoom():
zoom_icon_cord = None
# start gets the time at which this function starts executing
start = time.time()
now = time.time()
while zoom_icon_cord == None:
while (now - start) < 50: # As long as time elapsed (now - start) is less than 50 seconds, it will keep searching for the image
print("Finding Zoom Icon...")
zoom_icon_cord = pag.locateCenterOnScreen("all_icons\icon_zoom.png", confidence=0.7)
now = time.time() # Gets the current time (in seconds) to update the time eleapsed
# If the image is found, then do...
if zoom_icon_cord != None:
pag.click(zoom_icon_cord, clicks=2)
print("\nFound Zoom Icon!\n")
return True
# If time elapsed is greater than 50 sec, it stops the current function (find_zoom()) by returning False
else:
print("\nCould not find Zoom icon on Desktop! \n")
return False
def find_join_plus_icon():
join_plus_cord = None
start = time.time()
now = time.time()
while join_plus_cord == None:
while (now - start) < 50:
print("Finding Join Plus Icon...")
join_plus_cord = pag.locateCenterOnScreen("all_icons\join_plus_icon.png", confidence=0.8)
now = time.time()
if join_plus_cord != None:
pag.click(join_plus_cord)
print("\nFound Join Plus Icon! \n")
return True
else:
print("\nCould not find Join Plus Icon! \n")
return False
def find_join_meeting_window(meeting_id):
join_grey_btn = None
start = time.time()
now = time.time()
while join_grey_btn == None:
while (now - start) < 50:
join_grey_btn = pag.locateOnScreen("all_icons\join_grey_btn.png", confidence=0.7)
now = time.time()
if join_grey_btn != None:
pag.write(meeting_id, interval=0.07)
print("Finished typing Meeting ID \n")
pag.click(pag.locateCenterOnScreen("all_icons\join_btn.png", confidence=0.7))
#pag.press("enter")
return True
else:
print("\nCould not type Meeting ID! \n")
return False
def find_meeting_password_window(meeting_pswd):
join_meet_grey_btn = None
m_p_img = None
start = time.time()
now = time.time()
while join_meet_grey_btn == None and m_p_img == None:
while (now - start) < 50:
join_meet_grey_btn = pag.locateCenterOnScreen("all_icons\join_meeting_grey_btn.png", confidence=0.7)
m_p_img = pag.locateCenterOnScreen("all_icons\m_password_img.png", confidence=0.7)
now = time.time()
if join_meet_grey_btn != None:
pag.write(meeting_pswd)
print("Finished typing Meeting Password \n")
pag.click(pag.locateCenterOnScreen("all_icons\join_meeting_btn.png", confidence=0.7))
#pag.click("enter")
return True
else:
print("\nCould not type Meeting Password! \n")
return False
if __name__ == "__main__":
main()