There are a lot of fun pranks you can play on your friends with a computer. You’ve probably seen all of those creepy YouTube videos that people forward to each other for a good scare. Not long ago, Justin covered a few really funny ways to prank your parents with a computer too. All of those ideas are fun, but this year, how about creeping out your friends a bit with your very own programming skill?
In this article, I’m going to show you how you can create your own little Windows script that will run on just about any modern Windows computer. All you have to do is open up Notepad, type up this script, save it as a .wsf file and then have your friends open up the file. The script will automatically open up Notepad and then start typing – complete with typewriter sound effects – just like the computer itself is possessed by a typing ghost.
The real beauty of this little script is how creative you are with launching it. Insert it into the computer’s startup folder so it launches when the computer starts, or replace one of their favorite desktop shortcuts to link to your file instead of their application!
Scripting A Possessed Typing Computer
The idea for this came from an experience at college, when I walked past a professor’s office and saw that he had an old DOS computer that was typing all by itself. He was a Computer Science professor, and he’d clearly written a DOS program that could type all by itself, complete with sound effects, pauses and everything. Very authentic. In this article, you’re going to do the same thing, just with Windows and using VB Script to accomplish the job. I’ll walk you through the process.
First step – download a typewriter WAV file from any of your favorite free WAV file websites.
Preferably download one that lasts from 30 seconds to a minute, depending on how much text you want your phantom app to type on the screen by itself. Save the file to c:/windows/Media/ with the rest of the Windows sound files so it’ll be easy to find later.
Next, open up a text file and save it as a .wsf file. In my case I called it “phantomtype.wsf“. Declare all of the required variables, set up your text file link and then type the text that you want your typing ghost app to type on the screen.
<job> <script language="VBScript"> Option Explicit On Error Resume Next Dim NoteShell Dim SoundShell Dim strText Dim intTextLen Dim x Dim intPause Dim strTempText strSoundFile = "C:\Windows\Media\typewriter1.wav" strText = "Hello. My name is Ryan. I have possessed your computer
and there is nothing you can do about it. Of course, I suppose you
can always close the window if you want to, but that wouldn't be any fun!"
Pretty simple so far right? The two “Shell” variables are basically the shell commands that are going to launch Notepad and your sound file. The phantom typing will come from your script sending keystrokes to the Notepad app behind the scenes. Accomplishing that is easy – you just use “CreateObject” to set up your two application objects, and then launch each app, waiting a tiny bit between each launch.
Set NoteShell = CreateObject("WScript.Shell") Set SoundShell = CreateObject("Wscript.Shell") NoteShell.Run "notepad" WScript.Sleep 1000 SoundShell.Run "C:\Windows\Media\typewriter1.wav", 0, True WScript.Sleep 500
Now, the victim will see Notepad pop up on the screen, and after a second, the typewriter typing sound will start. At that moment, you will start sending ghostly text to the screen, just like someone is sitting there typing. Here’s how that part works.
intTextLen = Len(strText) intPause = 100 For x = 1 to intTextLen strTempText = Mid(strText,x,1) NoteShell.SendKeys strTempText WScript.Sleep intPause If intPause <= 500 Then intPause = intPause + 100 Else intPause = 100 End If Next
This may look complicated, but don’t worry, it’s not at all. The first line checks the length of the long string of text that you typed up at the start of this program. That’s the text that you want to magically appear – one letter at a time – on the screen. The next line creates a starting pause (a tenth of a second) between each typed letter.
The For loop that you see below that basically starts at position 1, extracts a single letter from your text, sends that letter to Notepad, and then waits a little bit before moving forward to the next letter in your text. Pretty cool huh?
And to keep things authentic, the little “IF” statement keeps adding and subtracting pause time between typed letters to make the whole thing look really authentic, like someone is sitting right there typing.
Now close up the script.
WScript.Quit </script> </job>
Save the file again – making sure you’ve got the “wsf” extension – and you’re done. Double click the file and check out your haunted computer!
Here’s my script in action (I wish you could hear the typing sounds, it’s a riot!)
Like most programs, it could use a little perfecting if you’re up to it. The sound file needs to match the amount of time it takes for the typing to finish. Or, you could loop both the typing and the sound, but you’ll need to come up with a way to let the person close the typing ghost application. If you don’t, the “sendkeys” will just continue typing no matter what window they open…which, is actually a pretty funny virus-like behavior, but not something that I would recommend you do to your friends.
So give this creepy little script a try and let us know what your friends thought about it. Did you come up with any other ways to perfect it? Share your thoughts in the comments section below.
Image Credit : Shutterstock
More articles about: