-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebexAPI.py
177 lines (155 loc) · 6.9 KB
/
WebexAPI.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import pyautogui, time, pyperclip, random, warnings
SkinMode="Dark" #Dark and Light
def GetSkin():
JoinButton=pyautogui.locateCenterOnScreen('resources/DarkMode/JoinMeeting.png', grayscale=True, confidence=0.7)
if JoinButton:
SkinMode="Dark"
else:
JoinButton=pyautogui.locateCenterOnScreen('resources/LightMode/JoinMeeting.png', grayscale=True, confidence=0.7)
if JoinButton:
SkinMode="Light"
def Join(url: str):
GetSkin()
time.sleep(3)
JoinButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/JoinMeeting.png', grayscale=True, confidence=0.7)
if JoinButton:
click(JoinButton,1)
def Leave():
LeaveButton=pyautogui.locateCenterOnScreen('resources/ExitMeeting.png', grayscale=True, confidence=0.9)
if LeaveButton:
click(LeaveButton,1)
time.sleep(1)
LeaveButton=pyautogui.locateCenterOnScreen('resources/ConfirmLeave.png', grayscale=True, confidence=0.9)
if LeaveButton:
click(LeaveButton,1)
def click(OBJ,nclicks: int):
pyautogui.moveTo(OBJ)
pyautogui.click(OBJ, clicks=nclicks)
def GetWaitStatus():
status=0
WaitStatus=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/WaitingForHost.png', grayscale=True, confidence=0.9)
if WaitStatus:
print("Host didn't join yet")
status=1
if not WaitStatus:
WaitStatus=pyautogui.locateCenterOnScreen('resources/WaitForHostAdmission.png', grayscale=True, confidence=0.9)
if WaitStatus:
print("Waiting to be accepted...")
status=2
else:
print("Either you are already in, or you are just not in yet.")
status=0
return status
def Chat(msg):
def GetChatStatus():
st=False
EnterMessage=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/EnterMessage.png', grayscale=True, confidence=1)
if EnterMessage:
st=True
return st
def Type(obj,msg):
click(obj,1)
pyperclip.copy(msg)
pyautogui.hotkey("ctrl", "v")
pyautogui.press("enter")
ChatCollapsed=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/ChatCollapsed.png', grayscale=True, confidence=0.9)
if not GetChatStatus():
print("Opening Chat")
if not ChatCollapsed:
ChatButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/ChatButton.png', grayscale=True, confidence=0.9)
if ChatButton:
click(ChatButton,1)
time.sleep(1)
else:
EnterMessage=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/EnterMessage.png', grayscale=True, confidence=1)
if EnterMessage:
click(ChatCollapsed,2)
EnterMessage=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/EnterMessage.png', grayscale=True, confidence=0.9)
Type(EnterMessage, respones[int(random.uniform(0,2))])
elif ChatCollapsed:
click(ChatCollapsed,2)
Type(EnterMessage, respones[random.uniform(0,2)])
else:
Type(EnterMessage, respones[random.uniform(0,2)])
class Peripherals():
def Microphone(enable: bool) -> int:
res=0 #0 Failed, 1 Success, 2 Mic is locked by host
def Get():
res=False #False off, True on
MicButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/MuteButton.png', grayscale=False, confidence=0.9)
if MicButton:
res=True
else:
res=False
return res
if not enable: #If user wants to mute
if not Get(): #If it's currently used
MicButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/UnmuteButton.png', grayscale=False, confidence=0.9)
if MicButton:
print("Already muted.")
else:
print("User is muted and locked by host.")
res=2
else: #If it's currently being used
MicButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/MuteButton.png', grayscale=False, confidence=0.9)
if MicButton:
click(MicButton,1)
print("Done")
res=1
else: #If we want to enable it
if Get(): #If it's enabled
MicButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/UnmuteButton.png', grayscale=False, confidence=0.8)
if MicButton:
print("Opening Mic...")
click(MicButton,1)
res=1
else:
MicButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/MuteButton.png', grayscale=False, confidence=0.9)
if MicButton:
print("Mic already enabled.")
else:
print("User is muted and locked by host.")
res=2
else:
return res
def Camera(enabled: bool) -> int:
def Get():
res=False #False Closed, True Open
VideoButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/StopVideoButton.png', grayscale=True, confidence=0.9)
if VideoButton:# If we detect that the canera is currectly open
res=True
else:
res=False
return res
res=0
if not enabled:
if Get(): #If camera is open
VideoButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/StopVideoButton.png', grayscale=True, confidence=0.9)
if VideoButton:
print("Closing Video...")
click(VideoButton,1)
res=1
else:
print("Camera already closed.")
else: # user wants to close camera
if not Get():
VideoButton=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/StartVideoButton.png', grayscale=True, confidence=0.9)
if VideoButton:
print("Enabling Camera...")
click(VideoButton, 1)
res=1
else:
print("Camera already enabled.")
return res
def Hand(Raise: bool):
Me=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/Me.png', grayscale=True, confidence=0.9)
if Raise:
click(Me,1)
HandR=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/RaiseHand.png', grayscale=True, confidence=0.9)
click(HandR,1)
else:
HandR=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/HandRaisedSelected.png', grayscale=True, confidence=0.9)
if not HandR:
HandR=pyautogui.locateCenterOnScreen('resources/'+SkinMode+'Mode/HandRaisedUnselected.png', grayscale=True, confidence=0.9)
if not HandR: #Again...
print("Maybe the hand wasn't risen in the first place?!")