!Smart Package Robot 's VB-Script Support

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > VB-Script >

!Smart Package Robot 's VB-Script Support

Smart Package Robot 's VB-Script Support

Previous Top Next


 

Smart Package Robot 's VB-Script-Support

 

 

 

graphic

 

 

In Wikibooks there is an Introduction to VBS:

https://www.de.wikibooks.org/wiki/Visual_Basic_Script_(VBS):_Einf%C3%BChrung

 

See also here:
        WSH-Reference

 

 

 

An A-Z Index of Windows VBScript commands

 

   Abs(number)     Absolute (positive) value of number

  .AppActivate     Activate running command

  .Application     BrowseForFolder/Open

   Array(el1,el2,el3)   Add values to an Array variable

   Arguments       Command line arguments

   Asc(String)     Return ASCII code for string

   AscW(String)    Return Unicode code for string

  .BrowseForFolder Prompt the user to select a folder

C

   Call subroutine (arguments) or  subroutine arguments

   CBool(expression)  Convert expression to Boolean (True/False) •

   CByte(expression)  Convert expression to Byte (0-255) •

   CCur(expression)   Convert expression to Currency (numeric) •

   CDate(expression)  Convert expression to Date •

   CDbl(expression)   Convert expression to Double (up to 1.79x10308) •

   Chr(ChrCode)       Return the string character for ChrCode (ASCII code)

   ChrB(ChrCode)      Return the string character for ChrCode (Byte code)

   ChrW(ChrCode)      Return the string character for ChrCode (Unicode/DBCS)

   CInt(expression)   Convert expression to Integer •

   CLng(expression)   Convert expression to long •

   CSng(expression)   Convert expression to single •

   CStr(expression)   Convert expression to a string •

  .CreateObject     Create an automation object / run an external command

  .CreateShortcut   Create Shortcut

   cscript          Run a VBScript .vbs file

  .CurrentDirectory Retrieve or change the current directory

D

   Date()         The current system date

   DateAdd        Add a time interval to a Date

   DateDiff       Return the time interval between two dates

   DatePart       Return part of a given date

   DateSerial     Return a Date from a numeric Year, Month and Day

   DateValue      Return a Date from a string expression 

   Day(date)      Return the day component of date (1-31)

   Dim            Declare a new variable or array variable

   Do..Loop       Repeat a block of statements

   Drives

   Drive Map     .MapNetworkDrive - .Enum - .Remove

E

  .Echo           Echo text to screen, also StdOut.Write /.Popup

   End            End a procedure or code block

   Environment Variables  - Expand - .Delete/Remove

   Escape(String) Return only ASCII characters from a Unicode string.

   Eval(expr)     Evaluate an expression

  .Exec           Run a command

   Execute        Execute one or more  statements

   Exp(n)         Return e (base of natural logs) raised to a power n.

   Exit           Exit a block of code immediately

F

   FileSystemObject Work with Drives, Folders and Files

   Filter         Produce an array by filtering an existing array

   Fix(number)    Return the integer portion of a number

   For...Next     Repeat a block of statements a given number of times

   For Each...    Loop through the items in a collection or array

   FormatCurrency Format a number with a currency symbol

   FormatNumber   Format a number

   FormatPercent  Format a number with a % symbol

   FormatDateTime Format a Date/Time value

   Function       Define a function procedure

G

   GetLocale()    Return the Regional LocaleID

  .GetObject      Get an Automation object

H

   Hex(number)    Return the hex value of number

   Hour(time)     Return the hour component of time

I

   If..Then       Conditionally execute a block of statements

   InputBox       Prompt for user input

   InStr          Find one string within another

   InStrRev       Find one string within another, starting from the end

   Int(number)    Return the integer portion of a number

   IsArray(varname)      Is varname an array?

   IsDate(expression)    Is expression a DateTime? 

   IsEmpty(expression)   Is expression initialised?

   IsNull(expression)    Is expression NULL?

   IsNumeric(expression) Is expression a Numeric? 

   IsObject(expression)  Is expression an object?

   Join           Combine the contents of an array into a single variable. 

L

   LBound             Return the smallest subscript for an array.

   LCase(String)      Return String in lower case

   Left(String,len)   Return the leftmost len characters of string

   LeftB(String,len)  Return the leftmost len bytes of string

   Len(String)    Return length of string in characters

   LenB(String)   Return length of string in Bytes

   Log(number)    Return natural log of number

  .LogEvent       Log an item in the Event log

   LTrim(String)  Remove any leading spaces from a string expression    

M

  .MapNetworkDrive Drive Map     

   Mid            Return a mid-section from a string

   Minute(time)   Return the minute component of time

   Month(date)    Return the month component of date

   MonthName      Convert a month number to a descriptive Month

   MsgBox         Display a dialogue box message

N

  .Network        Access network resources

   Now            Return the current Date and Time

O

   On Error       Error handling

   Option Explicit   Force all variables to be defined

P

  .AddPrinterConn / .AddWindowsPrConn Add Printer connection

  .EnumPrinterConnections   List Printer connections

  .SetDefaultPrinter        Set default printer

  .RemovePrinterConnection  Remove printer connection

   Private VarName          Declare a local variable/array variable

   Public VarName           Declare a public variable/array variable

Q

  .Quit            Quit

R

   Randomize(number)   Initialise the random number generator

  .ReadLine       Accept user text input

   ReDim          Resize a dynamic array

   RegExp         Regular expression search object

  .RegDelete      Registry, delete

  .RegRead        Registry, read

  .RegWrite       Registry, write

   REM            Add a Comment

   Replace        Find and replace text

   RGB(Red,Green,Blue) Return a system color code

   Right(String,len)   Return the rightmost len characters of string

   RightB(String,len)  Return the rightmost len bytes of string

   Rnd            Return a random number  

   Round          Round a number to n decimal places

   RTrim(String)  Remove any trailing spaces from a string expression

  .Run a command

S

   Second(time)   Return the second component of time

   Select...Case  Conditionally execute a block of statements

  .SendKeys

   Set variable = object   Assign an object reference

   SetLocale(LocaleID)     Set the Regional LocaleID

   Sgn(number)             The sign of a number

  .Shell + Shell.Application objects/methods

  .ShellExecute   Run a script/application in the Windows Shell 

   Shortcut create .CreateShortcut

  .Sleep

   Space          Return a string consisting of spaces. 

  .SpecialFolders Path to Desktop,Start menu, Programs...

   Split          Parse a string of delimited values into an array

   Sqr(number)    Square root

   StrComp        Compare two strings

   String         Create a string with a single character repeated

   StrReverse     Reverse a string

   Sub            Declare a sub procedure

T

   Time()         The current system time

   Timer()        The number of seconds since midnight

   TimeSerial     Construct a Time value from Hours, Minutes and seconds

   TimeValue      Convert a string to a Time value

   Trim(String)   Remove leading and trailing spaces from string

   TypeName       Return variable type (variant subtype). 

U

   UBound         Return the largest subscript for an array dimension

   UCase(String)  Uppercase String

   UnEscape(Str)  Return Unicode characters from an escaped ASCII string

W

   Weekday        Return the day of the week (1-7)

   WeekdayName    Return the named day of the week

   While...Wend   Conditionally repeat a block of statements

   With           Assign multiple properties of an object

   Year(date)     Return the year component of date (1-12)

   ' Remark       Add a Comment

 

 All VBScript variables are variants (general Datatype for Numbers, Strings and Objects).

 

 

Sample-Usage:

-------------

 

 Dim a

 Set a = CreateObject("WScript.Shell")

 a.SendKeys "{Enter}"

 

 

 Key              Code

 ==========================

 BACKSPACE ----- {BACKSPACE}, {BS}, or {BKSP}

 BREAK --------- {BREAK}

 CAPS LOCK ----- {CAPSLOCK}

 DEL or DELETE - {DELETE} or {DEL}

 DOWN ARROW ---- {DOWN}

 END ----------- {END}

 ENTER --------- {ENTER}or ~

 ESC ----------- {ESC}

 CTRL ---------- ^

 ALT ----------- %

 HELP ---------- {HELP}

 HOME ---------- {HOME}

 INS or INSERT - {INSERT} or {INS}

 LEFT ARROW ---- {LEFT}

 NUM LOCK ------ {NUMLOCK}

 PAGE DOWN ----- {PGDN}

 PAGE UP ------- {PGUP}

 PRINT SCREEN -- {PRTSC}

 RIGHT ARROW --- {RIGHT}

 SCROLL LOCK --- {SCROLLLOCK}

 TAB ----------- {TAB}

 UP ARROW ------ {UP}

 F1 ------------ {F1}

 F2 ------------ {F2}

 F3 ------------ {F3}

 F4 ------------ {F4}

 F5 ------------ {F5}

 F6 ------------ {F6}

 F7 ------------ {F7}

 F8 ------------ {F8}

 F9 ------------ {F9}

 F10 ----------- {F10}

 F11 ----------- {F11}

 F12 ----------- {F12}

 F13 ----------- {F13}

 F14 ----------- {F14}

 F15 ----------- {F15}

 F16 ----------- {F16}

 

 

 

Sample-MACRO:

 

'Sample:

STW.ct|ConsoleWindowClass|Eingabeaufforderung

MLI.

VAR.$$NAM=DIR{ENTER}

%VB_Sendkeys $$NAM

ENR.

'------------------------------------

: %VB_Sendkeys

' Use TOS

#IF PARAMS=0

GSB.VB_Sendkeys|$tos$

#EIF

#IF PARAMS=1

GSB.VB_Sendkeys|§§§01

#EIF

END%

'------------------------------------

' P1 - Zu sendender Text

:VB_Sendkeys

SAV.Save|$$NAM

IVV.§§_00|=|1

  $$NAM=§§_01

ELS.

  $$NAM=Hallo Welt!{ENTER}

EIF.

' Auflösung da VBS. nur vorsichtig, binärkompatibel auflöst.

VAR.$$NAM=$$NAM

 

VBS.VB|Test|$$NAM

Option Explicit

  Function Test(x)

  Dim a

  Set a = CreateObject("WScript.Shell")

  a.SendKeys x(0)

  End Function

VBE.

SAV.Restore

RET.