I'm trying to make a script using the winsound, keyboard, and pyautogui modules. I want it to play when a pixel at the dedicated coordinates on screen is white and when the quit key (q) isn't pressed. Here is what I've tried
while keyboard.is_pressed("q") == False:
if pyautogui.pixel(343, 846) [0] == 255:
winsound.PlaySound("bt.wav", winsound.SND_FILENAME | winsound.SND_ASYNC)
else:
winsound.PlaySound(None, winsound.SND_PURGE)
I'm pretty sure this doesn't work because it just keeps looping trying to play the sound so it never actually starts. I probably explained this poorly so lmk if you need me to elaborate.