Sunday, 1 March 2015

Fun with Easy VBS!

A Beginners guide to fun, and easy to do visual basic script. VSB may seem hard to some, but in fact it is really easy. Windows can even run it without a compiler! If you know javascript, it should be really easy for you.

STEP 1: BASIC MESSAGE BOXES


Ok so lets go over the Basics.

Have you ever seen a message box like the one below,
you probaly have. These are used to alert users of whatever you want to say.

You can create your own by using the Function Msgbox

So the code to a message box that says hi would look like this,

Msgbox("hi")

Alternately you can make an unkillable message box by making a simple loop by using the Do, Loop commands.

Now that we covered message boxes, lets move to more advanced message boxes.
STEP 2: GAMES AND STUFF


If you ever wonder how to make text games than look no further. I might be wrong, but I believe that they used vbs. Now a lot of vb scripts use a compiler, but windows doesn't need one. Just type cscript before the file path, now if you know how to make bat files, then you can automate this process, but we wont get into that in this instructable.

Here is a little game i made

Option Explicit

Dim Answer

'types the question

Wscript.StdOut.Write "Nice Day Isin't it? "
answer = Wscript.StdIn.ReadLine

'if you type yes t

If answer="yes" Then
Wscript.echo ("I hope it stays this way")

'If you type no

ElseIf answer="no" Then

Wscript.echo ("I hope it gets better")

'anything else

Else

Wscript.Echo ("GoodDay to you")

'end

End If

now basically save this as .vbs and use the method before to run it.
STEP 3: THE AUTO TYPER


This code it to type something over and over again. I don't know how it is useful, but if you run it, you'll have to kill it in the task list

set shellobj = CreateObject("WScript.Shell")
shellobj.run "cmd"

do

shellobj.sendkeys "Y"
wscript.sleep 200
Shellobj.sendkeys "o "
wscript.sleep 200

loop

No comments: