Saturday, September 6, 2014

Simple script to do a countdown of 20 minutes: 'Stop Notification after 20 Minutes, Simple.vbs'

This is a very simple countdown timer for me to do a countdown of 20 minutes.

Why do I create this script? I want a simple timer on my Windows PC to make sure I do not spend too much time on any social networks.

Here is the source code listing:



'
' Copyright 2014 Li-Ji Hong (http://www.hongliji.info, mailto:hongliji@gmail.com)
' 
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
' 
'     http://www.apache.org/licenses/LICENSE-2.0
' 
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.'
'
' * Source Filename: 'Stop Notification after 20 Minutes, Simple.vbs'
'

Const SleepTimeInMs=1200000
Const WelcomeTitle="Welcome!"
Const WelcomeBody="Starting a Countdown of 20 Minutes ..."
Const NotificationTitle="Time's up!"
Const NotificationBody="Twenty minutes passed. It is time to stop, right now!"
Const intWelcomeSecondsToWait = 2

Set objShell = CreateObject("WScript.Shell")

objShell.Popup WelcomeBody, intWelcomeSecondsToWait, WelcomeTitle, vbInformation
WScript.Sleep SleepTimeInMs
CreateObject("SAPI.SpVoice").Speak NotificationBody
objShell.Popup NotificationBody, , NotificationTitle, vbInformation

' End of Script

I also put it on Google Drive in case you want to download.

Why Apache 2.0 License?

The reason for me to use Apache 2.0 license is because of this on GNU web site.


What if the work is not very long? (#WhatIfWorkIsShort)
If a whole software package contains very little code—less than 300 lines is the benchmark we use—you may as well use a lax permissive license for it, rather than a copyleft license like the GNU GPL. (Unless, that is, the code is specially important.) We recommend the Apache License 2.0 for such cases.

Timed Dialog

I was inspired by the comment of RobSampson under this post.


References:

Microsoft Windows 2000 Scripting Guide - Displaying Timed Message Boxes

No comments:

Post a Comment