paul1965 Posted February 13, 2021 Share Posted February 13, 2021 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 AutoItWinSetTitle($g_szVersion) 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) EndSwitch Link to comment Share on other sites More sharing options...
pseakins Posted February 13, 2021 Share Posted February 13, 2021 Have you looked at the help example for Switch? Coincidently, it covers almost the exact scenario you are seeking. BTW, there would never be a Case 24 as this would actually be zero. Phil Seakins Link to comment Share on other sites More sharing options...
paul1965 Posted February 13, 2021 Author Share Posted February 13, 2021 @pseakins If you mean have I checked Switch.au3, yest I have. But that still shows only the hour, not minutes and seconds. 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? Link to comment Share on other sites More sharing options...
pseakins Posted February 13, 2021 Share Posted February 13, 2021 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 comment Share on other sites More sharing options...
paul1965 Posted February 13, 2021 Author Share Posted February 13, 2021 53 minutes ago, pseakins said: No, there would be no gap in coverage with this example. Thanks for that info. I'll change my scripts to match the example and see what happens. Link to comment Share on other sites More sharing options...
paul1965 Posted February 14, 2021 Author Share Posted February 14, 2021 @pseakins My scripts work perfect; thanks for your prompt responses. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now