1

I just want a file I can double-click and have Windows verbally tell me the time every 15 minutes. (Until I kill the process)

I found this tutorial for a VBscript that tells the time every hour, on the hour: https://www.nextofwindows.com/windows-trick-how-to-make-your-computer-to-speak-out-time-at-every-hour

I couldn't get the Windows scheduler working with it for my purposes (start only when double-clicked and run every 15 minutes), and honestly, I just want a 15-minute-interval loop programmed into the script itself. (perhaps by using a Do/While loop and Sleep()?)

Another issue:

I tried adding a minutes variable so Windows would announce the minutes as well:

Dim speaks, speech
speaks = “It is ” & hour(time) & minute(time)
Set speech = CreateObject(“sapi.spvoice”)
speech.Speak speaks

However, it announces the time in an odd format this way. For example, It's currently 5:01AM, and when I run the script, Windows says "It is fifty-one." Why would it interpret 5:01 as fifty plus one? Earlier when I tested it at 4:32, it said "four hundred and thirty-two." I'd like it to just state the time in a normal 12-hour fashion.

velkoon
  • 871
  • 3
  • 15
  • 35
  • If you want to start it with a double click and have it speak every fifteen minutes, forget windows scheduler. Here's an example of how you make a VBScript do something at a regular time: http://stackoverflow.com/questions/25009516/vba-excel-conditional-message-box-popup-every-2-minutes-from-now. Looking at the site you linked to, the speech text is actually `5 oclock`. The speech text is not `5:00`. So I guess SAPI doesn't recognose time in that way. You need to generate the text yourself. This would be quite trivial if you split the hour and the minutes: i.e. `5` and `53` instead of `5:53` – Nick.Mc Feb 12 '17 at 12:28
  • 1
    @Nick.McDermaid VBScript is not the same as VBA, there is one `Application.OnTime` event handler in VBScript. – user692942 Feb 13 '17 at 10:40
  • Oh yes you're right. I didn't realise it was VBA – Nick.Mc Feb 13 '17 at 10:59

1 Answers1

4

This does 5 secs. So 60 x 15 = 900.

You need spaces between numbers if you want them parsed as individual numbers.

Set speech = CreateObject("sapi.spvoice")
Do
    If Hour(Now) < 12 then 
        Var = Hour(Now) & " AM"
    else
        Var = Hour(Now) - 12 & " PM" 
    End If

    speech.Speak Var &  " and " & Minute(Now) & " minutes and " & Second(Now) & " seconds"
    wscript.sleep 5
Loop
Freddie
  • 269
  • 1
  • 4