How to program "stop slouching !" message

Page 2 of 2 FirstFirst 12

  1. Posts : 1,210
    Windows 7 Ultimate x64 (XP, 98SE, 95, 3.11, DOS 7.10 on VM) + Ubuntu 10.04 LTS Lucid Lynx
       #11

    Hi pacman10

    I couldn't find any program that did what you wanted, so I wrote a simple script to read a simple text file and display a random line from that file.

    Code:
    <job id="vbs">
        <script language="VBScript">
            Set objFSO=CreateObject("Scripting.FileSystemObject")
            Set objReadFile=objFSO.OpenTextFile("Quotes.txt", 1)
            I=1
            Do Until objReadFile.AtEndOfStream
               Redim Preserve arrData(I)
               arrData(I)=Replace(objReadFile.ReadLine, "vbCrLf", (CHR(13) & CHR(10)))
               I=I+1
            Loop
            objReadFile.Close
    
            Randomize
            MyNumber=Int(Rnd()*UBound(arrData))+1
            'WScript.Echo MyNumber
    
            strContents=arrData(MyNumber)
            'WScript.Echo strContents
            MsgBox strContents, 0, "Quotes"
        </script>
    </job>
    You can save this to a file with the extension .wsf and create a shortcut with WScript "Path to the wsf file" anywhere. The data file 'Quotes.txt' must be in the same folder as the .wsf file.
    If you check the data file I've attached you'll find a few lines with vbCrLf. Wherever you add vbCrLf to a line, a line feed [ENTER] will be added.

    You can then use Task Scheduler to run the shortcut repetitively.
    Task Scheduler - Create New Task

    How to program &quot;stop slouching !&quot; message-quote.png

    I've attached the files also with this post.
    How to program &quot;stop slouching !&quot; message Attached Files
      My Computer


  2. Posts : 36
    Windows 7 64-bit
    Thread Starter
       #12

    Hi Gladson1976,

    Thanks very much indeed for taking the trouble to write this script. Very neat !

    I'm still trying to work out how to fire it up with Task Scheduler at, say, 6 hourly intervals. Task Scheduler only offers Daily, Weekly, etc. as options.

    You really ought to publish this script under a snappy name. I'm sure lots of people would use it. It could also be used to throw up aphorisms and jokes. Attached is a list of sayings that some people might like if it's their kind of style. Unfortunately I can't remember where this list came from. I don't like stealing things and would like to have been able to attribute it to its author or compiler.

    Anyway, back to finding out how Task Scheduler works !

    Thanks again.
    How to program &quot;stop slouching !&quot; message Attached Files
      My Computer


  3. Posts : 14,606
    Microsoft Windows 7 Home Premium 64-bit 7600
       #13

    well done gladson, some thing that occured to me when reading another thread about vocal messages on startup was that you could possibly have a recorded message and set it as a system sound , perhaps when closing a programme to say your message . not sure exactly how you would go about it but its a thought and if anyone knows how perhaps it could work, you could find a text to speach site where you can type your message then have sound effects and different voices (from anna)
    anyone?
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:42.
Find Us