Feb-09-2021, 04:13 PM
my mistake I was using the wrong path (c:\windows\test Should have been C:\test Sorry about that
The script runs now but If I change the time 16 to 11 (the time here is 11:10 the script still runs and plays a wav file
The wav file should only play between 9 and 11 (that's the way I read it)
The script runs now but If I change the time 16 to 11 (the time here is 11:10 the script still runs and plays a wav file
The wav file should only play between 9 and 11 (that's the way I read it)
import sys from os.path import isfile, join from os import listdir import random import datetime hr = datetime.datetime.now().hour if hr < 9 or hr > 11: sys.exit() #path you want to get wav files from path = "C:\Test" onlyfiles = [ f for f in listdir(path) if isfile(join(path,f)) ] onlywavfiles = [] for f in onlyfiles: if f[-3:] == "wav": onlywavfiles.append(f) #generate random number based on number of available files randomnum = random.randint(0,len(onlywavfiles)-1) eg.plugins.System.PlaySound(path + "/" + onlywavfiles[randomnum], 1, False)