Trying to use Pyautogui and playsound to play a sound when an image is displayed during Microsoft Teams

83 Views Asked by At

I am a fairly new coder and I am using Jupyter Notebook to write my pythong code.

I was trying to write a loop that would run pyautogui to constantly scan the screen for an image, when the image is displayed I want to play a sound using the playsound library. Unfortunately, I am having trouble writing a loop that will do so. I defined a master variable just as a placeholder variable to continue running the loop until res is filled. Wasn't sure how else I could do it and would love to hear any and all advice :)

I am trying to make this program to be able to run across programs because it has to be able to identify when an image is displayed on Microsoft Teams.

Thank you!

CODE BELOW:

#!/usr/bin/env python
# coding: utf-8

# In[10]:


from playsound import playsound


# In[1]:


import pyautogui


# In[2]:


from playsound import playsound


# In[3]:


master = None
res = None


# In[16]:


master = None
res = None
def func(): 
    while master == None:
        res=1
        master=res


# In[17]:


def func2():
    if master != None:
        return True


# In[ ]:


res = pyautogui.locateOnScreen(r"C:\Users\RohanSharma\Pictures\Polly.png")
        master = res


# In[ ]:


playsound (r"C:\\Users\RohanSharma\Music\alarm-car-or-home-62554.mp3")


# In[ ]:

I have tried to write a loop that will run the pyautogui program until the master variable is filled (when the res variable is filled). If the master variable is filled, play the sound car alarm.

0

There are 0 best solutions below