Jump to content

Run a specific sound file based on the time of day

Recommended Posts

I've been working on a script to play a specific email notification sound based on the time of day (morning, afternoon, evening). I have had some success using @HOUR, but I'd really like to get down to minutes and seconds. So from 00:00:00 to 11:59:59 the "morning" email notification will play, then from  12:00:00 to 16:59:59 the "afternoon" notification plays, then from 17:00:00 on to 23:59:59 the "evening" notification plays. I tried adding @HOUR & @MIN and $SEC to the script, but then got an error when running it. Can anyone point me in the right direction?

Here's what I've got so far, the problem  I think is the overlap in the hour specified:

$g_szVersion = "Comcast.au3"

If WinExists($g_szVersion) Then Exit ; It's already running


Switch @HOUR

   Case 00 to 12

SoundPlay("F:\Alerts\Comcast_Morning.wav", 1)

   Case 12 to 17

      SoundPlay("F:\Alerts\Comcast_Afternoon.wav", 1)

   Case 17 to 24

      SoundPlay("F:\Alerts\Comcast_Evening.wav", 1)


Link to post
Share on other sites
9 minutes ago, paul1965 said:

I made an assumption that there is a gap in coverage between 11 and 12, 17 and 18, and so on and so on. Is that not the case?

No, there would be no gap in coverage with this example.

Phil Seakins

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...