PDA

View Full Version : AutoTalker with VBSCript



pinoyid0l
01-31-2009, 01:08 PM
Simple AutoTalker with Text File

Just for information, I provided a simpler version of auto made with VBScript in General Help. Now that I am a junior member and not yet confident to develop and release something useful in "First Scripts" section, here I am providing another VBscript based autoTalker.


Why make with VBScript?
-since most people doesn't trust compiled counter parts (eg VB6, C/C++, etc), VBScript provides open source, yet easy to understand within the VB programmer's circle (or anyone familiar with programming). And what more, you are never required to have a full pledged compiler, just refer to Instructions and you'll discover why.

-[ignore this] and why make scar, in pascal based syntax? pascal seemed to be messy with begin/end everywhere (unlike with modern languages, C++/Java, VB, etc)


Why autotalker?
-why not? :duh: well, most of the stuff starts from somthing...


Grammar errors
-sorry for that, but I'm doing my best, even though English is not my native nor second language.





'simple Auto Talker with Text File.
'pinoyid0l with VBscript

'Description: Ever wanted to auto type the entire text in a text file,
' like you favorite song? if not, go away. lol

'REQUIREMENTS:
'1)windows platform


'INSTRUCTIONS:
'1) copy the code to notepad
'2) edit the values of variables within the ===EDIT THIS=== part below.
'3) save to any filename with [.vbs] extension (eg. AutoTalker.vbs)
'4) run the script by simply double clicking it.
'5) set your focus within runescape, (click anywhere within the runescape client)
'6) it should work, or review the steps.

'POSSIBLE USAGE:
'1) If a windows computer doesn't have scar or doesn't allow you to. (school, office, other's pc, etc)
'2) Takes up less memory, and probable usage sparingly with scar scripts.






'ISSUES:
'1) The computer is blocked from running any script.



'========EDIT THIS=========
Const textPath = "stat.txt" 'If textfile is in same directory with the script, input text file name
'Else if textfile is not in the same directory, input full path with text file name (eg "C:\sample.txt")

Const iCounter = 1 'the number of times the the content will be auto typed.

'========END EDITING======

Set wshShell = wscript.CreateObject("WScript.Shell")

Call init()


Sub init()
Dim objFSO

wscript.sleep 5000 'gives you 5 seconds to set focus on your desired environment to type in.

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(textPath, 1)
Do Until objFile.AtEndOfStream
typeSend(objFile.Readline)
Loop

End sub


sub typeSend(str)
Dim i
Randomize

For i = 1 To Len(str)
wshshell.sendkeys Mid(str,i,1)
wscript.sleep Int( (101) * Rnd + 100 )

next

wshshell.sendkeys "{enter}"
wscript.sleep Int( (301) * Rnd + 500 )
End sub