Introduction: VBScript Tutorial
VBScript is a programming language, that is built in in most Windows PCs.
To get started, open Notepad, or any other notepad, and type in MsgBox("Hello, World!"). Run it, and you will see "Hello, World!" and a OK button.
To get started, open Notepad, or any other notepad, and type in MsgBox("Hello, World!"). Run it, and you will see "Hello, World!" and a OK button.
Step 1: InputBox
Now, let's make a simple Inputbox. It's similar to "MsgBox", but with "InputBox".
InputBox("What is your name?") Run that, you will see "What is your name?" and a Inputbox.
Now, you have only seen some of the powerful features that VBS has.
InputBox("What is your name?") Run that, you will see "What is your name?" and a Inputbox.
Now, you have only seen some of the powerful features that VBS has.
Step 2: Speak!
Many people think that they can make a computer talk. That is true, with VBS.
Turn your speakers on, and type this into Notepad.
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Hello."
-------------------------------------------------------------------------
That was MS Anna speaking. Try this:
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Look!"
do
wscript.sleep 200
wshshell.sendkeys "{NUMLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 200
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{NUMLOCK}"
loop
-----------------------------------------------------------------
You computer will say "Look!" and then flash the LOCK buttons.
Press Ctrl+C to stop it.
Turn your speakers on, and type this into Notepad.
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Hello."
-------------------------------------------------------------------------
That was MS Anna speaking. Try this:
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Look!"
do
wscript.sleep 200
wshshell.sendkeys "{NUMLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 200
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{NUMLOCK}"
loop
-----------------------------------------------------------------
You computer will say "Look!" and then flash the LOCK buttons.
Press Ctrl+C to stop it.
Step 3: Calling "370 VBS"
Calling VBS from a Batch file.
Let's see: You have a Batch file and you want to have VBS in it. You can't have VBS 'in' it, but you can call the VBS script.
VBS Script:
--------------------------------------------------------
MsgBox("Hello!")
--------------------------------------------------------
Batch File:
--------------------------------------------------------
start "C:\Users\You\Desktop\something.vbs"
--------------------------------------------------------
Start the batch, and, it will start "something.vbs" instead.
Let's see: You have a Batch file and you want to have VBS in it. You can't have VBS 'in' it, but you can call the VBS script.
VBS Script:
--------------------------------------------------------
MsgBox("Hello!")
--------------------------------------------------------
Batch File:
--------------------------------------------------------
start "C:\Users\You\Desktop\something.vbs"
--------------------------------------------------------
Start the batch, and, it will start "something.vbs" instead.