The following list describes key functions you can use in yourscripts. Each list item contains information about a function, its syntax, any arguments you need to supply, an example of the function, and the results of the example.
AppGetData
This function returns a screen element.
- Syntax
-
String appGetData(int hwnd, String Path, String Type)
- Arguments
- Use FindWindow to get the identifier of the
window (hwnd). The type can be any of the following quoted strings. “Value”
is the default.
- Name
- Description
- Window
- Value
- Example
-
Point = appGetData(hwnd, "POINT(150,200)", "Value") Path = appGetData(hwnd, "4|4|4|3|4|1|1|1|1|1|1|1|4|1|5|1", "Value") Name = appGetData(hwnd, "1|2^Test|4|1|1|3", "Value")
- Result
- Result is “Smith, John F”.
AppGetDataVisible
This function returns a screen element from a visible window.
- Syntax
-
String appGetDataVisible(int hwnd, String Path, String Type)
- Arguments
- Use FindWindow to get the identifier of the
window (hwnd). The type can be any of the following quoted strings. “Value”
is the default.
- Name
- Description
- Window
- Value
- Example
-
Point = appGetDataVisible(hwnd, "POINT(150,200)", "Value") Path = appGetDataVisible(hwnd, "4|4|4|3|4|1|1|1|1|1|1|1|4|1|5|1", "Value") Name = appGetDataVisible(hwnd, "1|2^Test|4|1|1|3", "Value")
- Result
- The result is “Smith, John F”.
ClipboardGetData
This function returns data from a DOS or terminal application using the clipboard.
- Syntax
-
string ClipboardGetData(int hwndSelectedWind, int Position, int Length, int ConnectionDelay, int ConnectionRetries, string ConnectionString)
- Arguments
- Int hwndSelectWind is the window handle of the application plan.
- Terminal Capture Arguments
- Int ConnectionDelay sets the delay in the seconds between connection attempts.
- Example
-
window = FindWindow("Test App") results = ClipboardGetData(window, 0, 20, 5, 5, "57634;")
- Result
- The result is “Smith, Jones”.
DeleteChars
This function deletes all specified characters.
- Syntax
-
STR DeleteChars(STR SourceStr, STR CharsStr)
- Arguments
- String rawValue is the string from which you want to remove characters.
- Example
-
WorkingValue = DeleteChars(folder, "()- ")
- Result
- The string "(913) 111-1111" becomes "9131111111".
DeleteCharsOfType
This function deletes the specified characters of a certain type.
- Syntax
-
STR DeleteCharsOfType(STR SourceStr, STR TypeStr)
- Arguments
- “p” specifies punctuation.
- Example
-
WorkingValue = DeleteCharsOfType(folder, "pa")
- Result
- The string “abc9999..” becomes “9999”.
DeleteRangeOfChars
This function parses a string and deletes the specified amount of characters from that string.
- Syntax
-
STR DeleteRangeOfChars(STR SourceStr, int StartPos, int Len)
- Arguments
- String rawValue is the string from which to remove characters.
- Example
-
WorkingValue = DeleteRangeOfChars(folder, 0, 3)
- Result
- The string “abcdefgh” becomes “defgh”.
DoMacroAlpha
This function removes all non-alphabetic characters.
- Syntax
-
STR DoMacroAlpha(STR rawValue)
- Arguments
- String rawValue is the string of non-alphabetic characters you want to remove.
- Example
-
msgbox "Alpha: " + DoMacroAlpha("a1@b2#c3$")
- Result
- The string “a1@b2#c3$” becomes “abc”.
DoMacroAlphaNumeric
This function removes all non-alphanumeric characters.
- Syntax
-
STR(STR rawValue)
- Arguments
- String rawValue is the string from which to remove non-alphanumeric characters.
- Example
-
msgbox "AlphaNumeric: " + DoMacroAlphaNumeric("a1@b2#c3$")
- Result
- The string "a1@b2#c3$" becomes “a1b2c3”.
DoMacroDateConversion
This function converts a string variable to a variable of date type.
- Syntax
-
STR(STR rawValue, string dateFormat)
- Arguments
- String rawValue is the string to convert to a date.
- Example
-
msgbox "Date: " + DoMacroDateConversion("OCT 16th, 1978", "MMM dd, yyyy")
- Result
- The string “OCT 16th, 1978” becomes “10/16/1978”.
DoMacroDeleteCharacters
This function removes specific characters from a string.
- Syntax
-
STR(STR rawValue", STR charsToDelete)
- Arguments
- String rawValue is the value from which to remove the characters.
- Example
-
msgbox "Delete Characters: " + DoMacroDeleteCharacters("INV-778989", "INV-")
- Result
- The string “INV-778989” becomes “778989”.
DoMacroLeadingZeros
This function removes leading zeros from a string.
- Syntax
-
STR(STR or int rawValue)
- Arguments
- String rawValue is the value from which the leading zeros are removed.
- Example
-
msgbox "Remove Zeros: " + DoMacroLeadingZeroes("000012345")
- Result
- The string “000012345” becomes “12345”.
DoMacroFixedLength
This function returns the designated amount of characters from a string.
- Syntax
-
STR DoMacroFixedLength(STR rawValue, int length, bool fromLeft)
- Arguments
- String rawValue is the value to convert.
- Example
-
msgbox "Fixed Length (left): " + DoMacroFixedLength("abcdefg", 4, true)
- Result
- The string “abcdefg” returns “abcd”.
DoMacroNumberConversion
This function returns a value of type number.
- Syntax
-
STR(STR or int rawNum, int numOfDecimals, char separator)
- Arguments
- String or integer rawNum is the value to format as a number.
- Example
-
msgbox "Number: " + DoMacroNumberConversion("1234.12", 0, ".")
- Result
- The string “1234.12” becomes “1234”.
DoMacroNumeric
This function converts a string variable to a numeric variable.
- Syntax
-
STR(STR rawValue)
- Arguments
- String rawValue is the string from which to remove non-numeric characters.
- Example
-
msgbox "Number: " + DoMacroNumber("INV-8899878")
- Result
- The string “INV-8899878” returns “8899878”.
DoMacroLineSearch
This function searches multiple lines based on the input string and extracts data from the specified line.
- Syntax
-
STR DoMacroLineSearch(STR Input, int LineNum, STR Direction, int StartPos, STR StopType, STR StopValue)
- Arguments
- String Input is the string to search.
- Example
-
input = "this is a test" & vbNewLine & "This is only a test" & vbNewLine & "Testing 1, 2, 3"
text1 = DoMacroLineSearch(input, 2, "Forward", "9", "Character Length", "6")
- Result
- The result string is “only a”.
- Additional information
- If StopType is "Character Length", StopValue is a number of characters to return. If StopType is "Stopping Characters", the StopValue is a character pattern that indicates where to stop the string returned.
DoMacroStaticSearch
This function searches for text based on the input string and returns text from the results.
- Syntax
-
STR DoMacroStaticSearch(STR Input, STR AnchorText, int LineOffset, STR Direction, STR StopType, STR StopValue)
- Arguments
- String Input is the string to search.
- Example
-
Input = "this is a test" & vbNewLine & "This is only a test" & vbNewLine & "Testing 1, 2, 3"
"Forward", "End Of Line",)
- Result
- The result string is “Testing 1, 2, 3”.
- Additional information
- If StopType is "Character Length", StopValue is a number of characters to return. If StopType is "Stopping Characters", the StopValue is a character pattern that indicates where to stop the string returned.
DoMacroUser
This function returns a value of type Perceptive Content username.
- Syntax
-
DoMacroUser(String userName)
- Arguments
- String userName is the user name to pass into Perceptive Content.
- Example
-
msgbox "User: " + DoMacroUser("jsmith")
- Result
- The result is “User:jsmith”.
DocProperty
This function can set a property for a document or return the desired value.
- Syntax
-
string DocProperty(string customPropName)
- Arguments
- String customProperty is the name of the custom property that needs to be set.
- Example
- DocProperty("Name") = " Jane Doe"
- Result
- The result string is “Name: Jane Doe”.
Field
This function can set or return the current value from an element in the dictionary.
- Syntax
-
string Field(string dictionaryElement)
- Arguments
- String dictionaryElement is the dictionary element name.
- Example
-
msgbox Field("Last Name")
- Result
- Returns the current value from the dictionary element called Last Name.
FolderProperty
This function can set a property for a folder or return a specific value.
- Syntax
-
string FolderProperty(string customPropName)
- Arguments
- String customPropName is the name of the custom property that needs to be set.
- Example
-
FolderProperty("Patient ID") = "9910552"
- Result
- The result string is “Patient ID: 9910552”.
FindWindow
This function searches the desktop for a window title that matches the argument.
- Syntax
-
int FindWindow(STR WindowTitle)
- Arguments
- String WindowTitle is the title to search for and can include wildcards (* or ?)
- Example
-
hwnd = FindWindow("Internet Explorer")
- Result
- The result is an integer that identifies the window in the system.
- Additional information
- The returned value is most useful when used as the first parameter to AppGetData.
GetActiveScreenName
This function returns the user defined screen name that Perceptive Content is currently using.
- Syntax
-
GetActiveScreenName()
- Example
-
msgbox GetActiveScreenName()
- Result
- Returns the current user defined screen name.
GetINowINIString
This function reads a string from the imagenow.ini"file.
- Syntax
-
string GetINowINIString(string SectionName, string KeyName)
- Arguments
- String SectionName is the name of the section in the INI file to search for the key.
- Example
-
Result = GetINowINIString("Logon Settings", "Default")
- Result
- Result contains the name of the default Perceptive Content connection profile.
GetScreenText
This function gets the text on the screen at the supplied x and y coordinates, to the specified length.
- Syntax
-
String GetScreenText(int Xpos, int Ypos, int Len)
- Arguments
- Integer Xpos is the horizontal position of the first character retrieved with a value of 1 indicating the leftmost character.
- Example
-
WorkingValue = GetScreenText(0, 8, 15)
- Result
- The result string is “City: Crestview”.
HyperlearnCreateFont
This function creates the font string necessary for HyperlearnGetData.
- Syntax
-
string HyperlearnCreateFont(string fontName, int fontSize, int Weight, int Italic)
- Arguments
- String fontName is the name of the font.
- Example
-
font = HyperlearnCreateFont("Courier", 12, 400, 0)
- Result
- The result string is “-11,0,0,0,400,0,0,0,0,0,0,0,0,Courier”.
HyperlearnGetData
This function extracts the text from an area of a window using Hyperlearn technology.
- Syntax
- string HyperlearnGetData(int selectedWindow, int left, int top, int width, int height, string font)
- Arguments
- Integer hwndSelectWind is the window handle from which to get data. Use the FindWindow() method to get the window handle.
- Example
-
hwnd = FindWindow("PSI higher Ed Demo")
- Result
- The text extracted from the area at pixel coordinates 100, 200 with a width of 50 pixels and a height of 16 pixels from the window titled "PSI Higher Ed Demo."
- Additional information
- HyperlearnCreateFont creates the font string. You must first add fonts to the application plan to receive results.
IntToStr
This function converts an integer to a string.
- Syntax
-
String IntToString(int Num)
- Arguments
- Integer Num is the integer value to convert to a string format.
- Example
-
s=IntToString(99)
- Result
- The result string is “99”.
- Additional information
- This method was deprecated in version 6.7. Replace it with the Visual Basic Scripting method, CStr.
LogError
This function writes a message to the client log file.
- Syntax
-
void LogError(String message)
- Arguments
- Message to be written to the log
- Example
-
LogError(“an error occurred in the LearnMode script”)
- Result
- The result string is added to the client log file.
LogWarning
This function writes a message to the client log file.
- Syntax
-
void LogWarning(String message)
- Argument
-
Message to be written to the log
- Example
-
LogWarning(“something happened in the LearnMode script”)
- Result
- If the client log level is 1 or greater, the string is added to the client log file. If the client log level is 0, then no action is taken.
NameReorder
This function converts a string that contains a first name, a space, and a last name to a last name, comma, first name format.
- Syntax
-
STR NameReorder(STR SourceStr)
- Arguments
- String SourceStr is the string that is reordered.
- Example
-
WorkingValue = NameReorder(folder)
- Result
- The string “John Doe” becomes “Doe, John”.
PostDocProperty
This function can set a property for a folder or return the desired value.
- Syntax
-
string PostDocProperty(string customPropName)
- Arguments
- String customPropName is the name of the custom property that needs to be set.
- Example
-
PostDocProperty("Patient ID") = "9910552"
- Result
- The string result is “9910552”.
PostField
This function can set the current value or return from an element in the dictionary.
- Syntax
-
string PostField(string dictionaryElement)
- Arguments
- String dictionaryElement is the dictionary element name.
- Example
-
msgbox PostField("Last Name")
- Result
- Returns the current value from the dictionary element called Last Name.
PostFolderProperty
This function can set a property for a folder or return a specific value.
- Syntax
-
string PostFolderProperty(string customPropName)
- Arguments
- String customPropName is the name of the custom property that needs to be set.
- Example
-
PostFolderProperty("Name") = " Joe Smith"
- Result
- The result string is “Name: Joe Smith”.
SetFocus
Searches for a named window and gives it input focus.
- Syntax
-
int SetFocus(string windowTitle)
- Arguments
- String windowTitle is the title of the window for which to search.
- Example
-
success = SetFocus("PSI Higher Ed Demo")
- Result
- The window titled "PSI Higher Ed Demo" moves to the foreground and has input focus. Success equals 1 if the window is found.
SetForeground
This function finds the window with a given handle and gives it input focus.
- Syntax
-
int SetForeground(Int64 hWnd)
- Arguments
- Integer hWnd is the window handle that receives focus.
- Example
-
hwnd = FindWindow("PSI Higher Ed Demo")
- Result
- The window titled "PSI Higher Ed Demo"moves to the foreground and has input focus. Success equals 1 if the window is found.
ShellOpen
This function launches a program or a file.
- Syntax
-
ShellOpen(String Command)
- Arguments
- Command is a program or a file to open.
- Example
-
ShellOpen("c:\Somefile.txt")
- Result
- NotePad opens with c:\Somefile.txt loaded. The calculator application also is opened.
Sleep
This function establishes the amount of time to pause without doing anything.
- Syntax
-
void Sleep(int msec)
- Arguments
- Supply the time for msec in milliseconds.
- Example
-
Sleep(100) ' 1/10th of a second
- Result
- The script is paused for 1/10th of a second.
SwipSwapFromBegin
This function takes a specified number of characters from the beginning of a string and moves them to the end of the string.
- Syntax
-
STR SwipSwapFromBegin(STR SourceStr, int Len)
- Argument
- Supply the string in SourceStr. Integer Len is the number of characters to take, starting at the beginning of the string.
- Example
-
WorkingValue = SwipSwapFromBegin(folder, 3)
- Result
- The string result is “abcdefgh” becomes “defghabc”.
SwipSwapFromEnd
This function takes a specified number of characters from the end of a string and moves them to the beginning of the string.
- Syntax
-
STR SwipSwapFromEnd(STR SourceStr, int Len)
- Arguments
- Supply the string in SourceStr. Integer Len is the number of characters to take, starting at the end of the string.
- Example
-
WorkingValue = SwipSwapFromEnd(folder, 3)
- Result
- The result string “abcdefgh” becomes “fghabcde”.
SwipSwapFromPos
This function moves a specified number of characters from one position to another in a string.
- Syntax
-
STR SwipSwapFromPos(STR SourceStr, int StartPos, int Len, int EndPos)
- Arguments
- Supply the string in SourceStr. Integer
- Example
-
WorkingValue = SwipSwapFromPos(folder, 4, 2, 1)
- Result
- The string “abcdefgh” becomes “aefbcdgh”.
Term
This function searches for windows to close based on "CLASS" or "TITLE."
- Syntax
-
int Term String Mode, String Name, String Command
- Arguments
- String Mode specifies how to search for windows to close based on "CLASS", or "TITLE." "CLASS" searches for windows with a class that exactly matches the Name parameter. "TITLE" searches for windows whose title text contains the Name parameter.
- Example
-
Term = "TITLE," "NotePad," "QUIT."
- Result
- All open NotePad windows are closed.
TopMsg
This function displays a window with the specified text.
- Syntax
-
TopMsg(string message)
- Arguments
- String message is the message to display.
- Example
-
TopMsg = "Hello World"
- Result
- A dialog box displays the text "Hello World" inside.
WindowTitle
This function returns a specified number of characters in the window title of the current window.
- Example
-
myWindowTitle = WindowTitle
- Result
- The string result is “PSI Banking Demo”.
WinGetData
This function returns text from a window using WindowWalker.
- Syntax
-
string WinGetData(int windowHandle, string directions)
- Arguments
- Integer selectedWindow is the handle to the window from which to get data. Use the FindWindow() function to get the window handle.
- Example
-
hwnd = FindWindow("PSI Higher Ed Demo")
- Result
- The result string is “206528888”.
Testing VB script functions
The Test button in the script editor does not always produce valid results when using these functions. To test your code, save the template, close the application plan, and then click on the icon in the Perceptive Content toolbar to view the results.