Clipboard.getText() => string strText
Gets text from the clipboard. Returns false if clipboard is empty.
Clipboard.saveImage(string strImageFilename) => bool bStatus
If there is an image in the clipboard, save image to a file. The following file formats are supported: .bmp, .gif, .jpg, .png, .tiff.
Clipboard.setText(string strText)
Sets text of clipboard.
Control.click(string strWindow, string strControl, string strBtn="left", int nClicks=1, int x=default, int y=default)
There are many ways to simulate clicking a button on a dialog. Using pixel coordinates is somewhat fragile, even when specifying coordinates relative to the current window. It's best to use a keyboard shortcut if possible.Otherwise, one of these Control methods can be used.[[br]][[br]]First, use the WindowInfo or WinExplorer.exe tool to find the ID and/or class of the control (button, text field, etc.).[[br]][[br]]Now in your script you can use either the ClassName, Text, or Control ID as the "sControl" parameter. Use sWindow="" for the current window, or refer to Window.activate documentation for more options.[[br]][[br]]Control.click sends a simulated mouse click to a control. Optionally specify button, number of clicks, or position of click (defaulting to center). Specify a control in one of three ways: ClassName (e.g. "Button", or "Button3" for the third Button control), Text (e.g. "OK" or "&Next" for a button with the text Next, with underlined N), or Control ID (e.g. 350, can be found with tools like Window Info Tool / spy).
Control.exists(string strWindow, string strControl) => bool bExists
Determines if a control exists. Specify a control in one of three ways: ClassName (e.g. "Button", or "Button3" for the third Button control), Text (e.g. "OK" or "&Next" for a button with the text Next, with underlined N), or Control ID (e.g. 350, can be found with tools like Window Info Tool / spy).
Control.getDimensions(string strWindow, string strControl) => int width, int height
Gets dimensions of control on form.
Control.getHandle(string strWindow, string strControl) => string strHandle
Get internal handle of a control. Result is returned as a string, or null if control is not found.
Control.getPosition(string strWindow, string strControl) => int x, int y
Gets position of control on form.
Control.getText(string strWindow, string strControl) => string strControlText
Retrieves the text from a control. Up to 16K can be retrieved.
Control.move(string strWindow, string strControl, int x, int y, int width=-1, int height=-1) => bool bSuccess
Moves a control. You can optionally provide a new width and height to move and resize in one step.
Control.resize(string strWindow, string strControl, int width, int height) => bool bSuccess
Resizes a control.
Control.sendCommand(string strWindow, string strControl, string strCommand, string strArgument="") => string strResult
Send command to a control. Result is returned as a string, unless the value is 0 in which case it is returned as the integer 0. strArgument is an additional argument to send to the control. Common commands include: [[br]]"IsVisible" Returns 1 if visible, 0 otherwise [[br]]"IsEnabled" Returns 1 if enabled, 0 otherwise [[br]]"ShowDropDown" Drops a ComboBox [[br]]"HideDropDown" Undrops a ComboBox [[br]]"AddString", 'string' Adds a string to the end in a ListBox or ComboBox [[br]]"DelString", occurrence Deletes a string according to occurrence in a ListBox or ComboBox [[br]]"FindString", 'string' Returns occurrence ref of the exact string in a ListBox or ComboBox [[br]]"SetCurrentSelection", occurrence Sets selection to occurrence ref in a ListBox or ComboBox [[br]]"SelectString", 'string' Sets selection according to string in a ListBox or ComboBox [[br]]"IsChecked" Returns 1 if Button is checked, 0 otherwise [[br]]"Check" Checks radio or check Button [[br]]"UnCheck" Unchecks radio or check Button [[br]]"GetCurrentLine" Returns the line # where the caret is in an Edit [[br]]"GetCurrentCol" Returns the column # where the caret is in an Edit [[br]]"GetCurrentSelection" Returns name of the currently selected item in a ListBox or ComboBox [[br]]"GetLineCount" Returns # of lines in an Edit [[br]]"GetLine", line# Returns text at line # passed of an Edit [[br]]"GetSelected" Returns selected text of an Edit [[br]]"EditPaste", 'string' Pastes the 'string' at the Edit's caret position [[br]]"CurrentTab" Returns the current Tab shown of a SysTabControl32 [[br]]"TabRight" Moves to the next tab to the right of a SysTabControl32 [[br]]"TabLeft" Moves to the next tab to the left of a SysTabControl32. Example.
if (Control.sendCommand("Untitled", "Button2", "IsChecked")) print ('it is checked');[[br]] print('contents of line 3 are:'+Control.sendCommand("Untitled","Edit1", "GetLine", "3"));
Control.sendCommandListview(string strWindow, string strCtrl, string strCmd, string strArg="", string strArg2="") => string strResult
Sends a command to a ListView32 control. All indices are 0 based (first item referenced by 0 and so on). Some commands take two arguments. In a "Details" view, the "item" is the "row" and the "subitem" is the "column". Commands include: [[br]]"DeSelect", From [, To] Deselects one or more items. [[br]]"FindItem", "string to find" [, SubItem] Returns the item index of the string. Returns -1 if the string is not found. [[br]]"GetItemCount" Returns the number of list items. [[br]]"GetSelected" [, option] Returns a string containing the item index of selected items. If option=0 (default) only the first selected item is returned. If option=1 then all the selected items are returned delimited by |, e.g: "0|3|4|10". If no items are selected a blank "" string is returned. [[br]]"GetSelectedCount" Returns the number of items that are selected. [[br]]"GetSubItemCount" Returns the number of subitems. [[br]]"GetText", Item, SubItem Returns the text of a given item/subitem. [[br]]"IsSelected", Item Returns 1 if the item is selected, otherwise returns 0. [[br]]"Select", From [, To] Selects one or more items. [[br]]"SelectAll" Selects all items. [[br]]"SelectClear" Clears the selection of all items. [[br]]"SelectInvert" Inverts the current selection. [[br]]"ViewChange", "view" Changes the current view. Valid views are "list", "details", "smallicons", "largeicons". Example.
Control.sendCommandListview("C:\\Program Files","SysListView321","Select", "2", "5");
Control.sendText(string strWindow, string strControl, string strKeys, bool bRaw) => bool bSuccess
Send simulated keystrokes to a control (even if the window is not active). The string can include <Shift>, <Control>, <Ctrl>, <Alt>, as well as many others: {SPACE}, {ENTER}, {BACKSPACE}, {DELETE} (see Keyboard.send). <Alt> or <Win>, and other characters may not work equivalently to Keyboard.send.
Control.setEnabled(string strWindow, string strControl, bool bEnabled) => bool bSuccess
Set if a control is enabled or disabled, i.e. "grayed out".
Control.setFocus(string strWindow, string strControl) => bool bSuccess
Sets focus to a given control on a window.
Control.setText(string strWindow, string strControl, string strControlText) => bool bSuccess
Sets text of control.
Control.setVisible(string strWindow, string strControl, bool bVisible) => bool bSuccess
Set if a control is visible or hidden.
Dialog.alert(string strTitle, string strText)
Display simple message box on the screen. Example.
Dialog.alert("Information","Hello, world");
Dialog.askColor() => array rgb
Opens Windows color picker. Returns results as r,g,b values from 0-255. Returns false if canceled or timeout.
Dialog.askOkCancel(string strTitle, string strText) => Dialog.OK or Dialog.CANCEL
Display simple message box on the screen, with options for ok and cancel. Example.
var res = Dialog.askOkCancel("Status","Continue?");[[br]] if (res==Dialog.OK) doSomething();[[br]] else doSomethingElse();
Dialog.askYesNo(string strTitle, string strText) => Dialog.YES or Dialog.NO
Display simple message box on the screen, with options for yes and no. Example.
var res = Dialog.askYesNo("Status","Continue?");[[br]] if (res==Dialog.YES) doSomething();[[br]] else doSomethingElse();
Dialog.askYesNoCancel(string strTitle, string strText) => Dialog.YES;Dialog.NO;Dialog.CANCEL
Display simple message box on the screen, with options for yes, no, cancel. Example.
var res = Dialog.askYesNoCancel("Warning","Replace existing file?");[[br]]if (res==Dialog.YES) doSomething();[[br]]else if (res==Dialog.NO) doSomethingElse();[[br]]else doCancel();
Dialog.error(string strTitle, string strText)
Display simple message box on the screen, error icon.
Dialog.input(string strTitle, string strPrompt, string strDefaultText="") => string strResult
Opens input dialog for the user to type a response. Returns '' if user presses cancel.
Dialog.openFile(string strFiletype="*", bool bMult=false, string strStartDir=".") => string strFile
Opens standard Open File dialog. Provide type in format such as 'bmp', NOT '*.bmp'. If not multiple, returns string of filepath or false on cancel or timeout. If multiple, returns an array of strings: if the user chooses one file, ar[0] is the entire filepath and file name. if the user chooses > one file, ar[0] is the directory, and ar[1] to the rest are only the file names.
Dialog.saveFile(string strFiletype="*", string strStartDir=".") => string strFile
Opens standard Save File dialog. Provide type in format such as 'bmp', NOT '*.bmp'. Returns string of filepath or false on cancel or timeout.
Dialog.toolTip(string strText, int x=default, int y=default)
Creates a tooltip anywhere on the screen. If the x and y coordinates are omitted, the tip is placed near the mouse cursor. If the coords would cause the tooltip to run off screen, it is repositioned to visible. Tooltip appears until it is cleared, until script terminates, or sometimes until it is clicked upon. You may use a linefeed character to create multi-line tooltips. Example.
Dialog.toolTip("That's cool");[[br]] Time.sleep(500);[[br]] Dialog.toolTip("");
Dialog.warning(string strTitle, string strText)
Display simple message box on the screen, warning icon.
File.cd(string strDirectory="") => bool bSuccess
Change the current directory. This affects subsequent calls to functions that affect files. If no argument is given, returns the current working directory.
File.copy(string strFilename, string strCopyname) => bool bSuccess
Create a copy of a file. Will not replace an existing file.
File.copyMany(string strSource, string strDestination)
Copy an entire directory to another location. One can also copy many files, specifying '*.txt' to copy all text files in the current directory. May sometimes display a window. Example.
File.copyMany('c:\\temp1\\folder1','c:\\temp2\\'); /* copies entire folder. */[[br]] File.copyMany('c:\\temp\\*.*','d:\\destination');
File.createDirectory(string strDirectory) => bool bSuccess
Create an empty directory, by default in the current directory (which can be changed with File.cd() ).
File.createShortcut(string strFilename, string strTarget) => bool bSuccess
Create a shortcut (.lnk on Windows). Will not replace an existing file. Example.
File.createShortcut('shortcut.lnk','c:\\program files\\my program\\program.exe');
File.dirCountEntries(string strDirectory) => int nEntries
Counts how many files and subfolders are in the folder.
File.dirListFiles(string strDir, string strTypes="*", string strSortBy="Unsorted") => arFiles
Returns array of filenames inside folder. Provide a pattern like '*.txt' to only include .txt files. By default unsorted, but provide a flag such as 'unsorted', 'name','time','size','type'. Includes files marked as hidden, but not those marked as system. Example.
var arFiles = File.dirListFiles('c:\\','*','size');[[br]] print('biggest files in c:');[[br]] arFiles.reverse();[[br]] for(var i=0;i<arFiles.length;i++) print(arFiles[i]);
File.dirListSubdirs(string strDir, string strSortBy="Unsorted") => arDirs
Returns array of folder names that are subfolders of the folder. By default unsorted, but provide a flag such as 'unsorted', 'name','time','type'. Includes files marked as hidden, but not those marked as system. Example.
var arFolders = File.dirListSubdirs('c:\\','name');[[br]] print('subfolders in c:');[[br]] for(var i=0;i<arFolders.length;i++) print(arFolders[i]);
File.driveMapAdd(string strDevice, string strRemoteShare, bool bAuthDialog=0, string strUser="", string strPass="") => bool bR
Maps a network drive. strDevice is the device to map, for example "O:" or "LPT1:", or "" which makes a connection that is not mapped to a specific drive, or "*" to select an unused drive letter. strRemoteShare, in form "\\server\share". strUser, in form "username" or "domain\username" Example.
File.driveMapAdd("K:","\\\\myserver\\folder")
File.driveMapAddPersistant(string strDevice, string strRemoteShare, bool bAuthDialog=0, string strUser="", string strPass="") => bool bR
Maps a network drive. strDevice is the device to map, for example "O:" or "LPT1:", or "" which makes a connection that is not mapped to a specific drive, or "*" to select an unused drive letter. strRemoteShare, in form "\\server\share". strUser, in form "username" or "domain\username"
File.driveMapDialog()
Opens standard "Map Network Drive" dialog.
File.driveMapDisconnect(string strDrive) => bool bSuccess
Disconnects network drive. Provide drive letter "X:" or, if necessary, connection name "\\server\share".
File.driveMapInformation(string strDrive) => string strInformation
Retreives the details of a mapped drive. Returns details of the mapping, e.g. \\server\share. Returns number -1 upon failure. Example.
print(File.driveMapInformation('X:'));
File.exists(string strFile) => bool bExists
Test if the file or directory exists.
File.getAbsPath(string strFilepath) => string strAbsPath
Find absolute path from a relative path.
File.getPathHome() => string strPath
Return the directory of the current user's profile, typically something like C:/Documents and Settings/Username. If nothing is found, may fall back to c:\
File.getPathSpecial(SpecialFolder folder) => string strPath
Get the path of a special folder, such as SpecialFolder.MyDocuments. See also openExplorerWindowSpecial. Example: File.getPathSpecial(SpecialFolder.AppData); Also: [[br]]SpecialFolder.AppData[[br]] SpecialFolder.AllUsers[[br]]SpecialFolder.Cookies[[br]]SpecialFolder.Desktop[[br]]SpecialFolder.Favorites[[br]]SpecialFolder.AppDataLocalSettings[[br]]SpecialFolder.MyDocuments[[br]]SpecialFolder.MyPictures[[br]]SpecialFolder.ProgramFiles[[br]]SpecialFolder.ProgramFilesCommon[[br]]SpecialFolder.RecentDocuments[[br]]SpecialFolder.StartMenu[[br]]SpecialFolder.StartupItems[[br]]SpecialFolder.System[[br]]SpecialFolder.Windows[[br]]
File.getPathTemp() => string strPath
Return the system's temporary directory.
File.getShortcutTarget(string strFilename) => string strTarget
Find the target of a shortcut (.lnk on Windows). Example.
var strTarget = File.getShortcutTarget('shortcut.lnk'); if (File.exists(strTarget)) print('target exists');
File.getSize(string strFile) => int nSizeInBytes
Returns the file size in bytes. (May not work for files > 2 Gb in size).
File.getTimeAccessed(string strFile) => int nSecondsSince1970
Returns the date and time when the file was last accessed, as an integer. (Seconds since 1970-01-01 UTC). On platforms where this information is not available, returns the same as Modified(). Example.
var d = new Date(); d.setTime(File.getTimeAccessed('test.txt')*1000);
File.getTimeCreated(string strFile) => int nSecondsSince1970
Returns the date and time when the file was created, as an integer. (Seconds since 1970-01-01 UTC). Example.
var d = new Date(); d.setTime(File.getTimeCreated('test.txt')*1000);
File.getTimeModified(string strFile) => int nSecondsSince1970
Returns the date and time when the file was last modified, as an integer. (Seconds since 1970-01-01 UTC). Example.
var d = new Date(); d.setTime(File.getTimeModified('test.txt')*1000);
File.iniDeleteSection(string strFilename, string strSection) => bool bSuccess
Deletes a section from a standard format .ini file. Returns false if section is not found or if INI file is read-only.
File.iniDeleteVal(string strFilename, string strSection, string strKey) => bool bSuccess
Deletes a value from a standard format .ini file. Returns false if section/key is not found or if INI file is read-only.
File.iniReadVal(string strFilename, string strSection, string strKey) => string strValue
Reads a value from a standard format .ini file. If the key is not found, returns false. Reads 1024 bytes maximum.
File.iniWriteVal(string strFilename, string strSection, string strKey, string strValue) => bool bSuccess
Writes a value to a standard format .ini file. If file does not exist, it is created. Keys and/or sections are added to the end and are not sorted in any way. Returns false if file is read-only.
File.isDirectory(string strFilepath) => bool bDirectory
Test if it is a directory (folder).
File.isReadable(string strFile) => bool bReadable
Test if the current user has read permissions for the file.
File.isWritable(string strFile) => bool bWritable
Test if the current user has read permissions for the file.
File.openExplorerWindow(string strDirectory, bool bTreeView=false)
Opens new explorer window.
File.openExplorerWindowSpecial(SpecialFolder folder)
Open a folder in explorer, such as SpecialFolder.MyDocuments. See also getPathSpecial. Supports all available in File.getPathSpecial and also: [[br]]SpecialFolder.ControlPanel[[br]]SpecialFolder.Fonts[[br]]SpecialFolder.Printers[[br]]SpecialFolder.MyComputer[[br]]SpecialFolder.MyDocuments[[br]]SpecialFolder.MyNetworkPlaces[[br]]SpecialFolder.NetworkComputers[[br]]SpecialFolder.NetworkConnections[[br]]SpecialFolder.PrintersAndFaxes[[br]]SpecialFolder.RecycleBin[[br]]SpecialFolder.ScheduledTasks
File.pathJoin(string strPath, string strFilename) => string strCompletePath
(Write include('<std>') to import this function.) Combines a directory and filename to create a path. For example, File.pathJoin('c:\docs\foo\', 'test.txt') becomes 'c:\docs\foo\test.txt'
File.pathSplit(string strPath) => [string strPath, string strFile]
(Write include('<std>') to import this function.) Splits a directory into two parts. 1) the path, and 2) the filename. For example, 'c:\docs\foo\test.txt' to ['c:\docs\foo\', 'test.txt']
File.readFile(string strFile, bool bTextMode=true) => string strContents
Read text from a file. (Not recommended for binary files).Throws exception if file not found or is not readable. If bTextMode is true, \r\n characters on Windows are converted to \n
File.removeDirectory(string strDirectory) => bool bSuccess
Remove an empty directory, by default in the current directory (which can be changed with File.cd() ).
File.removeFile(string strFilename) => bool bSuccess
Delete a file. Returns false if delete does not succeed.
File.rename(string strFilename, string strNewname) => bool bSuccess
Rename a file. Will not overwrite an existing file.
File.showInExplorer(string strFilename)
Opens new explorer window, and highlights file.
File.tray(string strDriveLetter, string strOpenOrClosed) => bool bSuccess
Opens or closes the CD Tray. Provide the string 'open' or 'closed'. Drive letter in format 'D:' or 'd:'. Works as expected with virtual cd drives. Example.
File.tray('D:', 'open'); File.tray('D:', 'closed');
File.writeFile(string strFile, string strText, bool bAppend=false, bool bTextMode=true)
Write text to a file. (Not recommended for binary files). Throws exception if file is not writeable. If bTextMode is true, newline characters are converted according to platform.
Internet.ieClearTemporary(string strOption)
Clear Internet Explorer temporary files or settings. Options are "Files" (to delete temporary internet files), "Cookies" (to clear cookies), "History" (to clear history), "Forms", "Passwords", and "All"
Internet.ieFavorites()
Opens Internet Explorer organize favorites dialog
Internet.openUrl(string strUrl)
Opens URL in the default browser.
Keyboard.send(string strKeySequence)
Sends simulated keystrokes to the active window. The string can include <Alt>, <Control> or <Cntrl>, <Shift>, and <Win> as well as many others: {SPACE}, {ENTER}, {BACKSPACE}, {DELETE}, {UP}, {DOWN}, {LEFT}, {RIGHT}, {HOME}, {END}, {ESCAPE}, {INSERT}, {PGUP}, {PGDN}, {F1}-{F12}, {TAB}, {PRINTSCREEN}, {LWIN}, {RWIN}, {NUMLOCK on}, {CAPSLOCK off}, {SCROLLLOCK toggle}, {BREAK}, {PAUSE}, {NUMPAD0}, {NUMPADMULT}, {NUMPADADD}, {NUMPADSUB}, {NUMPADDIV}, {NUMPADDOT}, {NUMPADENTER}, {APPSKEY}, {LALT}, {RALT}, {LCTRL}, {RCTRL}, {LSHIFT}, {RSHIFT}, {SLEEP}, {ALTDOWN}, {SHIFTDOWN}, {CTRLDOWN}, {LWINDOWN}, {RWINDOWN}, {ASC nnnn}, {BROWSER_BACK}, {BROWSER_FORWARD}, {BROWSER_REFRESH}, {BROWSER_STOP}, {BROWSER_SEARCH}, {BROWSER_FAVORITES}, {BROWSER_HOME}, {VOLUME_MUTE}, {VOLUME_DOWN}, {VOLUME_UP}. Send {{} or {}} to send literal brace characters. Example.
Process.open('notepad.exe');[[br]]Keyboard.send('hello');[[br]]Keyboard.send('<Control>s');[[br]]Keyboard.send('{UP}{DOWN}{TAB}{ENTER}'); Keyboard.send('<Control><Shift>f');
Keyboard.sendAscii(int nAsciiCode)
Sends ascii value to active window.
Keyboard.sendRaw(string strKeySequence)
Sends simulated keystrokes to the active window. Example.
Keyboard.sendRaw('<html>');
Keyboard.sendUnicode(int nUnicode)
Sends unicode value to active window.
Keyboard.setKeyDelay(int nKeyDelay)
Alters the the length of the brief pause in between sent keystrokes. Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.
Keyboard.setKeyDownDuration(int nKeyDownDuration)
Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default. Time in milliseconds to pause (default=1).
Mouse.click(int x=default, int y=default, bool bRelativeCds=false, string strBtn="left", int nSpeed=-1)
Moves cursor to x, y and sends simulated mouse click. If x and y are not specified sends mouseclick at current mouse position. If you specify bRelativeCds to be true, moves the cursor relative to window. You can pass the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.[[br]][[br]]Note that Keyboard.send('<Shift>{F10}') will simulate right-clicking on the focused item.
Mouse.doubleClick(int x=default, int y=default, bool bRelativeCds=false, string strBtn="left", int nSpeed=-1)
Moves cursor to x, y and sends simulated mouse double-click. If x and y are not specified sends clicks at current mouse position. If you specify bRelativeCds to be true, moves the cursor relative to window. You can pass the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.
Mouse.drag(int x1, int y1, int x2, int y2, bool bRelativeCds=false, string strBtn="left", int nSpeed=-1)
Perform a mouse click and drag operation. If x and y are not specified sends mouseclick at current mouse position. If you specify bRelativeCds to be true, moves the cursor relative to window. You can pass the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.
Mouse.getCursor() => int nCursorId
Returns a cursor ID Number:[[br]] 0 = UNKNOWN (this includes pointing and grabbing hand icons)[[br]] 1 = APPSTARTING[[br]] 2 = ARROW[[br]] 3 = CROSS[[br]] 4 = HELP[[br]] 5 = IBEAM[[br]] 6 = ICON[[br]] 7 = NO[[br]] 8 = SIZE[[br]] 9 = SIZEALL[[br]] 10 = SIZENESW[[br]] 11 = SIZENS[[br]] 12 = SIZENWSE[[br]] 13 = SIZEWE[[br]] 14 = UPARROW[[br]] 15 = WAIT
Mouse.getPosition() => [int x, int y]
Returns array of the current X and Y position of the mouse.
Mouse.mouseDown(string strBtn="left")
Simulate mouseDown. For every mouseDown there should eventually be a corresponding mouseUp.
Mouse.mouseUp(string strBtn="left")
Simulate mouseUp. For every mouseDown there should eventually be a corresponding mouseUp.
Mouse.move(int x, int y, bool bRelativeCds=false, int nSpeed=10)
Moves the cursor. If you specify bRelativeCds to be true, moves the cursor relative to its current position. You can pass the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.
Mouse.setClickDelay(int nMilliseconds)
For simulated mouse clicks, alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10).
Mouse.setClickDownDelay(int nMilliseconds)
For simulated mouse clicks,Alters the length a click is held down before release. Time in milliseconds to pause (default=10).
Mouse.setClickDragDelay(int nMilliseconds)
Alters the length of the brief pause at the start and end of a mouse drag operation. Time in milliseconds to pause (default=250).
Mouse.wheel(int nDisplacement)
Moves mouse wheel up or down. Pass 2 to scroll up two, pass -2 to scroll down two, and so on.
Process.close(string strExe)
Close a process. Names are executables without the full path, e.g., "notepad.exe". If multiple processes have the same name, the one closed is not necessarily the recently opened one. Example.
Process.close('notepad.exe'); [[br]]Process.close('1356'); //close process id 1356
Process.exists(string strExe) => int nPID
Checks to see if a process is running e.g., "notepad.exe". Returns the PID of the process, or 0 if process does not exist.
Process.open(string strExe, bool bPauseUntilItCloses=false, string strWorkingDir="", int nFlag=1) => int nPID
Opens external program. Optionally pass a flag such as Window.HIDE, Window.SHOW, Window.MINIMIZE, Window.MAXIMIZE, or Window.RESTORE. Returns the PID of process or null upon failure.
Process.openFile(string strFileOrUrlOrProgram, string strWorkingDir="")
Opens file, URL, or program with Windows shell (usually opens file in the default editor). After running the requested program the script continues (this is asynchronous).
Process.runAndRead(string strExe, string strWorkingDir="", int nTimeoutMs=30000) => string strOutput
Opens external program and reads its output from stdout. The script pauses until the program has closed. Throws exception if program cannot be found, and if process times out.
Process.runCmdLine(array arArguments) => [int retcode, string strStdout]
Execute array of strings in the command line shell, in the style of the command prompt cmd.exe. Waits until command completes. You must use quotes if a file or directory has spaces in the name. Example.
Process.runCmdLine(['mkdir', 'c:\\test\\myfolder']);
Process.runCmdLineString(string strCommandLineCommand, string strWorkingDir="")
Execute command line command, in the style of the command prompt cmd.exe. Waits until command completes. You must use quotes if a file or directory has spaces in the name. Example.
Process.runCmdLineString(@'mkdir c:\test\myfolder');
Process.setPriority(string strExe, int nPriorityLevel) => bool bSuccess
Changes the priority of a process. 0=Idle/Low, 4=High, 5=Realtime (use with caution). Levels 1 and 3 not supported on Win95/98/ME. Returns false upon failure. Names are executables without the full path, e.g., "notepad.exe" or "winword.exe".
Process.setServiceStatus(string strServiceName, string strAction) => bool bStatus
Start or stop a service or driver. Actions are "start","stop", "pause", "continue". Note some services cannot be stopped unless lnzscript is run as admin. Example.
Process.setServiceStatus("MySql","restart"); //restart Mysql service
Process.systemLock()
Lock computer.
Process.systemLogoff(bool bForce=false) => bool bSuccess
Log off current user. Optionally specify true to "force" logoff, which may result in unsaved data being lost. Returns false upon failure.
Process.systemRestart(bool bForce=false) => bool bSuccess
Restart computer. Optionally specify true to "force" restart, which may result in unsaved data being lost. Returns false upon failure.
Process.systemShutdown(bool bForce=false) => bool bSuccess
Shuts down system. Optionally specify true to "force" shutdown, which may result in unsaved data being lost. Returns false upon failure.
Process.waitUntilClosed(string strExe, int nTimeout=0) => bool bSuccess
Wait until process is closed. Optional parameter nTimeout specifies how long to wait (default is to wait indefinitely). Returns false if timed out. Names are executables without the full path, e.g., "notepad.exe" or "winword.exe".
Process.waitUntilOpen(string strExe, int nTimeout=0) => bool bSuccess
Wait until process is open. Optional parameter nTimeout specifies how long to wait (default is to wait indefinitely). Returns false if timed out. Names are executables without the full path, e.g., "notepad.exe" or "winword.exe".
Registry.deleteKey(string strKeyname) => int nResult
Deletes a key from the registry. Returns 1 upon success, 0 if key doesn't exist, -1 if error deleting key. Deleting from the registry is potentially dangerous--please exercise caution! A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC"). Example.
Registry.deleteKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\MyKey")
Registry.deleteVal(string strKeyname, string strValuename) => int nResult
Deletes a value from the registry. Returns 1 upon success, 0 if key doesn't exist, -1 if error deleting key. To access the (Default) value use "" (a blank string) for the valuename. Deleting from the registry is potentially dangerous--please exercise caution! A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC"). Example.
Registry.deleteKey("HKEY_LOCAL_MACHINE\\SOFTWARE", "TestValue")
Registry.listKeys(string strKeyname) => array astrSubkeys
Reads the names of subkeys of the given key. Returns an array of strings, or null if the key cannot be found.
Registry.listVal(string strKeyname) => array astrValueNames
Reads the names of values under the given key. Returns an array of strings, or null if the key cannot be found.
Registry.readVal(string strKeyname, string strValuename) => string strValue
Read value from the registry. Returns string value upon success, and boolean false on failure. To access the (Default) value use "" (a blank string) for the valuename. Supports registry keys of type REG_BINARY (returns hex string), REG_SZ, REG_MULTI_SZ (returns \\n delimited string), REG_EXPAND_SZ, and REG_DWORD. Cannot return more than 1024 bytes. A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC"). Example.
var strProgFiles = Registry.readVal("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFilesDir")
Registry.writeVal(string strKeyname, string strValuename, string strValue, string strType="REG_SZ") => bool bSuccess
Write value to registry. Returns false on failure. To access the (Default) value use "" (a blank string) for the valuename. Supports registry keys of type REG_BINARY (use hex string such as "01A9FF77"), REG_SZ, REG_MULTI_SZ (provide \\n delimited string - with no blank entries), REG_EXPAND_SZ, and REG_DWORD. A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC"). Example.
Registry.writeVal(""HKEY_LOCAL_MACHINE\\SOFTWARE", "TestKey", "Hello this is a test"); Registry.writeVal(""HKEY_LOCAL_MACHINE\\SOFTWARE", "TestKeyArray", "Hello\\n this\\n is\\n a\\n test", "REG_MULTI_SZ");
Rename.rename(string strSearch, string strReplace) => bool bSuccess
Rename strings in filenames. Use include('<std>') to import this. Rename does the following: for each file in the current directory (File.cd()), replace in the filename. Doesn't rename subdirectories. If a file cannot be renamed, throws an exception and leaves other filenames unchanged. Example.
include('<std>'); [[br]]File.cd(@'c:\mydir'); [[br]]Rename.rename('.htm', '.html');
Rename.renameFn(function fnRename, string strSorted='name') => bool bSuccess
Rename filenames. Use include('<std>') to import this. Provide a function that accepts a string and returns a string, the new name. Doesn't rename subdirectories. You can specify a sort order, which is useful when your function has state; this could be used to rename a set of files to 001, 002, 003... based on modification date. If a file cannot be renamed, throws an exception and leaves other filenames unchanged. Example.
include('<std>'); [[br]]File.cd(@'c:\mydir');[[br]] function myRename(s) {return 'new'+s;}[[br]] Rename.rename(myRename);
Rename.renameFnPreview(function fnRename, string strSorted='name') => bool bSuccess
Rename filenames. Use include('<std>') to import this. Prints the results of what Rename.renameFn would do, without actually renaming the files. Useful for testing.
Rename.renamePreview(string strSearch, string strReplace) => bool bSuccess
Preview before rename strings in filenames. Use include('<std>') to import this. Prints the results of what Rename.rename would do, without actually renaming the files. Useful for testing.
Screen.convertImage(string strImageFilename, string strNewImageName) => bool bStatus
Convert image file from one format from another. Image formats: .bmp, .gif, .png, .jpg, .tiff
Screen.copyScreenshot(bool bFullScreen=false)
Copy screenshot to the clipboard. Defaults to screenshot of the active window, specify true to take screenshot of full screen.
Screen.getColor(int x, int y, bool bRelCds=false) => [int nR, int nG, int nB]
Finds color of screen at coordinates. Returns array of r,g,b values (from 0 to 255), or null upon failure.
Screen.saveScreenshot(string strImageFilename, bool bFullScreen=false) => bool bStatus
Save screenshot to an image file. Defaults to screenshot of the active window, specify true to take screenshot of full screen. Current implementation overwrites clipboard contents. Image formats: .bmp, .gif, .png, .jpg, .tiff
Screen.searchPixelColor(int nR,int nG,int nB,int nLeft,int nTop,int nRight,int nBtm,bool bRelCds=0,int nStep=0,int nDiff=0) => bool bR
Search for color on screen. Returns coordinate at which color was found, or false. nStep - number of coordinates to walk with each step, make it larger for speed and less precision. nDiff - 0-255, are similar colors accepted? By default, 0, must be exact match. If given a value of 255, accepts different colors.
Sound.beep(int nFrequency=300, int nDurationMilliseconds=250) => bool bStatus
Plays a beep. If no frequency is given, plays standard Windows beep sound.
Sound.playSound(string strSoundFile="Default")
Play a wave file or standard Windows sound. Pass in the filepath of a WAV file, or one of the following:[[br]]"Asterisk"[[br]]"Default"[[br]]"Exclamation"[[br]]"Question"[[br]] Example.
Sound.playSound('c:/this/mysound.wav'); Sound.playSound('Welcome')
System.disableInput()
Disables mouse and keyboard input from the user. The script can, however, still simulate most mouse and keyboard events. Note that this has different effects based on operating system (and apparently does nothing on Vista). Pressing Ctrl+Alt+Del will re-enable input.
System.enableInput()
Enables mouse and keyboard input from the user after call to System.disableInput.
System.getenv(string strEnvironmentVariable) => string strValue
Get environment variable, or false upon error.
System.installScreensaver(string strScreensaver)
Installs a screensaver. Tested on Windows XP. On Vista, simply opens Screensaver options and doesn't work.
System.isAdmin() => bool bIsAdmin
Returns true if the current user has administrator privileges.
System.openControlPanel(ControlPanel panelOption)
Opens a control panel, i.e System.openControlPanel(ControlPanel.Display). Type "ControlPanel." in the editor and see autocomplete. Also, use System.openControlPanel(ControlPanelXp.Display) and so on for backwards compat. ControlPanel contains: Keyboard[[br]]Mouse[[br]]Joystick[[br]]Multimedia[[br]]InternetOptions[[br]]AddRemove[[br]]Regional[[br]]Time[[br]]System[[br]]Display[[br]]Accessibility[[br]]Network[[br]]Power[[br]]Accounts[[br]]SecurityCenter[[br]]Firewall[[br]]Wireless[[br]]Taskbar[[br]]FolderOptions[[br]]DeviceManager[[br]]Updates[[br]] Example.
System.openControlPanel(ControlPanel.Display);
System.openEjectHardware()
Opens "safely remove hardware" dialog.
System.openUtility(string strOption)
Opens a system utility. Options include: [[br]]Disk Cleanup[[br]]Disk Management[[br]]Services[[br]]Computer Management[[br]]Administrative Tools[[br]]Event Viewer[[br]]
System.windowsVersion() => string strVersion
Returns a string representing the windows version. '6.1'-Windows7,'6.0 Vista','5.1'-WindowsXP, '5.0'-Windows2000,,'5.2 Win server 2003' and so on. See msdn for more information.
Time.createTimer() => timer objTimer
Use include('<std>') to import this function. Creates a timer object that can be used for timing a script. Call the check() method on the timer to see how many milliseconds have passed after the object was created. Example.
include('<std>'); [[br]]var timer = Time.createTimer();[[br]] for (var i=0; i<30000; i++); print('number of ms:'+timer.check());
Time.sleep(int nMilliseconds)
Pauses script for this amount of time.
Window.activate(string strWindow) => bool bSucess
Activates (gives focus to) a window. You can use the WindowInfo tool to determine the class name of a window. Example.
Note: sWindow can be one of:[[br]][[br]]Window.activate('') - - - - - - - Currently active window.[[br]]Window.activate('Calc') - - - - - Window whose title starts with "Calc"[[br]]Window.activate('"Calculator"') - Window whose title is exactly "Calculator"[[br]]Window.activate('%ulator%') - - - Window with title containing "ulator" [[br]]Window.activate(object) - - - - - Instance of open "SciCalc" class with title "Calculator",[[br]]object = {title:'Calculator', class:'SciCalc'}
Window.callMenuItem(string strWindow, string strMenu, string strMenuItem, string strSubmenuItem="") => bool bSucess
Invokes a menu item of the window. Note that underlined menu items contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert". will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus.
Window.close(string strWindow, bool bForce=false) => bool bSucess
Closes a window. This function sends a close message to a window, the result depends on the window (it may ask to save data, etc.). To force a window to close, specify true (be warned that this will forcibly terminate the window if it doesn't close quickly enough, so a user might not have time to respond to dialogs prompting the user to save data). If multiple windows match the criteria, the window that was most recently active is closed.
Window.exists(string strWindow) => bool bSucess
Checks to see if a specified window exists.
Window.getCaretPosition(bool bRelativeCoords=false) => int x, int y
Returns the coordinates of the caret in the foreground window
Window.getClassList(string strWindow) => string strClassList
Retrieves the classes from a window, separated by \n (linefeed).
Window.getDimensions(string strWindow, bool bOnlyClientArea=false) => int width, int height
Returns the coordinates of the caret in the foreground window Example.
var desktopSize = Window.getDimensions('Program Manager'); //size of desktop
Window.getPosition(string strWindow) => int x, int y
Returns the coordinates of a window. Returns negative numbers such as -32000 for minimized windows.
Window.getProcessId(string strWindow) => string strPID
Retrieves the process ID of a window (as a string, use parseInt to convert it to a number).
Window.getStatusbarText(string strWindow, int nPart=1) => string strStatusbarText
Attempts to read the first standard status bar on a window (Microsoft common control: msctls_statusbar32). Some programs use their own status bars or special versions of the MS common control which StatusbarGetText cannot read. For example, StatusbarText does not work on the program TextPad, but Control.getText will work. Returns null upon failure.
Window.getText(string strWindow) => string strText
Retrieves the text from a window. Up to 16K can be retrieved.
Window.getTitle(string strWindow) => string strTitle
Retrieves the title from a window.
Window.getWindowsHandle(string strWindow) => string strHandleId
Retrieves the internal handle of a window (as a string, use parseInt to convert it to a number).
Window.includeChildWindows(bool bInclude)
By default, only top-level windows are searched. Run Window.includeChildWindows(true) to be able to manipulate child windows as well.
Window.isActive(string strWindow) => bool bSucess
Checks to see if a specified window exists and is currently active.
Window.isMaximized(string strWindow) => bool bMaximized
Is a given window maximized.
Window.isMinimized(string strWindow) => bool bMinimized
Is a given window minimized.
Window.maximize(string strWindow) => bool bSucess
Maximize a window. For more operations, see window.setState.
Window.minimize(string strWindow) => bool bSucess
Minimize a window. For more operations, see window.setState.
Window.minimizeAll()
Minimizes all windows. Use restoreAll to restore.
Window.move(string strWindow, int x, int y, int width=-1, int height=-1) => bool bSuccess
Moves a window. Negative values for x and y are allowed - you can move a window off screen. Has no effect on minimized windows. You can optionally provide a new width and height to move and resize in one step.
Window.resize(string strWindow, int width, int height) => bool bSuccess
Resizes a window. Has no effect on minimized windows, but works on hidden windows. If width and height are small (or negative), the window will go no smaller than 112 x 27 pixels. The window will go no larger than the size of the desktop.
Window.restore(string strWindow) => bool bSucess
Restores a minimized or maximized window. For more operations, see window.setState.
Window.restoreAll()
Restores all windows after a call to minimizeAll.
Window.setAlwaysOnTop(string strWindow, bool bOnTop=true) => bool bSucess
Change a window's "Always On Top" attribute, so that it is above other windows.
Window.setDelay(int nMillisecondsDelay)
By default, scripts pause for 250 ms after each successful window-related function. This delay can be changed.
Window.setState(string strWindow, int nFlag) => bool bSucess
Set state of a window (e.g. maximized, minimized). Pass a flag such as WindowStyle.hide, WindowStyle.show, WindowStyle.minimize, WindowStyle.maximize, or WindowStyle.restore.
Window.setTitle(string strWindow, string strTitle) => bool bSucess
Set title of window.
Window.setTransparency(string strWindow, int nTransparency) => bool bSucess
Set transparency, from 0 to 255. On Windows XP and later.
Window.wait(string strWindow, int nTimeout=0) => bool bBeforeTimeout
Pauses execution of the script until a window exists. Returns false if timed out. Polls for a window match every 250 milliseconds or so.
Window.waitUntilActive(string strWindow, int nTimeout=0) => bool bBeforeTimeout
Pauses execution of the script until a window is the active window. Returns false if timed out. Polls for a window match every 250 milliseconds or so.
Window.waitUntilClosed(string strWindow, int nTimeout=0) => bool bBeforeTimeout
Pauses execution of the script until a window is closed. Returns false if timed out. Polls for a window match every 250 milliseconds or so.
Window.waitUntilNotActive(string strWindow, int nTimeout=0) => bool bBeforeTimeout
Pauses execution of the script until a window is not active. Returns false if timed out. Polls for a window match every 250 milliseconds or so.
alert(string strMessage)
Open a dialog box displaying message. See Dialog.alert, which can also specify a title.
confirm(string strMessage) => bool bResponse
Open a dialog box displaying message, with options for yes and no. Returns true if yes, and false if no. See also Dialog.askYesNo, which has more options.
escape(string strInput) => string strOutput
Replaces non-ascii characters in the string with hex escape sequences.
eval(string strCode) => Object objResult
Parse strCode and run it as a script. If the parse fails, generate a runtime error.
include(string strScriptFilename)
Include a LnzScript file and execute it as if its contents were included directly. Use include('<std>') to include standard JavaScript code.
isArray(object obj)
Returns true if the object is an array. Use include('<std>') to import this function.
isFinite(number input) => bool bIsFinite
Returns false if the input is NaN, positive infinity, or negative infinity. Returns true otherwise.
isFunction(object obj)
Returns true if the object is a function. Use include('<std>') to import this function.
isNaN(number input) => bool bIsNotANumber
Returns true if the input is the value NaN, and false otherwise.
isNumber(object obj)
Returns true if the object is a number or can be used as a number. Use include('<std>') to import this function.
parseFloat(string strDigits) => fResult
The parseFloat function turns a string representation of a floating-point number into a number.
parseInt(string strDigits, int nBase) => int nResult
The parseInt function turns a string representation of a number into an integer. Example.
parseInt('135',10) == 135 //base 10
print(string strCode)
Print string or any object to the screen.
printarr(array ar)
Prints array, with indices. Use include('<std>') to import this function.
printobj(object obj)
Prints object, with keys. Use include('<std>') to import this function.
prompt(string strPrompt) => string strResult
Open a dialog box in which the user can enter text. Returns "" if the user presses cancel. See also Dialog.input, which has more options.
unescape(string strInput) => string strOutput
Restores original string from escape() function
arr.concat(array ar2) => array arCombined
Returns an array consisting of the elements of the original array followed by elements of the second array. (Combines two arrays).
arr.join(string strSeperator) => string strJoined
Combines an array of strings into one long string, delimited by seperator.
arr.pop() => value
The last element of the array is removed from the array and returned.
arr.push(value) => int nLength
A new element is appended onto the end of the array. The new length of the array is returned.
arr.reverse() => array arReversed
Reverses order of items in array.
arr.shift() => value
The first element of the array is removed from the array and returned.
arr.slice(int nStart, int nEnd) => array arSlice
Returns a new array that has elements from the slice of array. Example.
var a =[1,2,3,4,5]; b = a.slice(0,3); //1 2 3
arr.sort(function fnCompare=null) => array arSorted
Sorts elements of array. You can provide a custom comparison function. The comparison function should take 2 arguments, x,y, and return -1 if x<y, 0 if x==y, or 1 if x>y.
arr.unshift(value)
The value is prepended to the array, increasing the length by 1 and preserving the existing elements of the array.
new Date(int nYear, int nMonth, [int nDate, [int nHrs, [int nMins, [int nSec]]]]) => date objDate
Construct Date object
Date.UTC(int nYear, int nMonth, [int nDate, [int nHrs, [int nMins, [int nSec]]]]) => int nUtc
Calculate utc (coordinated universal time)
Date.getFullYear() => year
Returns year of date. See specification for more Date methods such as getMonth, getSeconds...
Date.getMilliseconds() => milliseconds
Returns milliseconds. See specification for more Date methods such as getMonth, getSeconds...
Date.getTime() => int nMilliseconds
Returns time from Jan1,1970 in milliseconds. If time is before this date, can be negative.
Date.parse(string strDate) => date dateOutput
Construct Date object from string Example.
var date = Date.parse('Janurary 7 1980');
Date.setFullYear(int nYear)
Set year of date. See specification for more Date methods such as setMonth, setSeconds...
Date.setMilliseconds(int nMilliseconds)
Returns milliseconds. See specification for more Date methods such as getMonth, getSeconds...
Date.setTime(int nMilliseconds)
Set time from Jan1,1970 in milliseconds. If time is before this date, can be negative.
dt.toString() => string strDate
Returns representation of date as a string. Example.
var date = Date.parse('Janurary 7 1980'); var s = date.toString();
Math.abs(input) => abs
Returns the absolute value of its argument (same magnitude but positive sign).
Math.acos(input) => arcCosine
Compute arccosine.
Math.asin(input) => arcSine
Compute arcsine.
Math.atan(input) => arcTan
Compute arctangent.
Math.atan2(y, x) => angleInRadians
Computes the angle in radians from the origin to the point (x,y).
Math.ceil(input) => int nOutput
Rounds up to next integer.
Math.cos(input) => fcos
Compute cosine.
Math.exp(input) => exp
Compute e to the (argument) power.
Math.floor(input) => int nOutput
Rounds down to an integer.
Math.log(input) => naturalLog
Compute natural (base e) logarithm. To use another base, use Math.log(x)/Math.log(base)
Math.max(a, b) => max
Returns larger of the arguments.
Math.min(a, b) => min
Returns smaller of the arguments.
Math.pow(x, power) => result
Returns x raised to a power.
Math.random() => fRandom
Returns pseudo-random between 0 and 1. The value is greater than or equal to 0 and less than 1.
Math.round(input) => int nOutput
Rounds to the closest integer. Also, if input is 3.5, rounds up to 4, and so on.
shuffleArray(array arr)
Shuffles (randomizes) order of elements in array. Use include('<std>') to import this function. Fisher-Yates algorithm. Note that apparently, initial random seed of lnzScript is the same, which is due to Qt library used.
Math.sin(input) => fsin
Compute sine.
Math.sqrt(input) => sqrt
Compute square root.
Math.tan(input) => ftan
Compute tangent.
x.toExponential() => string strNumber
Return number in exponential form (scientific notation).
x.toFixed(int nDigits) => string strNumber
Convert number to string, with given number of decimal digits. Example.
var n = 1.55555; print(n.toFixed(2));
x.toPrecision(int nDigits) => string strNumber
Return number with precision (uses rounding and scientific notation as necessary).
x.toString(int nBase=10) => string strNumber
Convert number to string, in the given base.
new RegExp(string strPattern, string strFlags="") => RegExp re
Creates RegExp object. Alternatively use the syntax /pattern/g instead of new RegExp('pattern','g'); Flags can include g (global), i (ignoreCase), m (multiline, anchors match at lines)
re.exec(string strString) => array arResults
Performs regex match on string, and returns an array of results. The first element of the array is the found string, and the remaining are captured subgroups. Example.
var re=/(\d+),(\d+)/;[[br]] var a = re.exec('12-2456'); //item 1 is 12, item 2 is 2456
s.charAt(int nIndex) => string strCharacter
Returns string containing character at position pos (where 0 refers to the first character). Example.
var s = "hello"; var h = s.charAt(0);
s.charCodeAt(int nIndex) => int nUnicode
Returns unicode or ascii value of character at position pos (where 0 refers to the first character).
s.contains(string strSmallerString) => bool bContains
Tests if string contains a certain substring. Use include('<std>') to import this function.
s.endsWith(string strSmallerString) => bool bEndsWith
Tests if string ends with a certain substring. Use include('<std>') to import this function.
String.fromCharCode(int nUnicode) => string strCharacter
Returns a string value, converting arguments into characters. Example.
var a = String.fromCharCode(97);
s.indexOf(string strSearch, int nPosition=0) => int nIndex
Searches for strSearch inside the string, and returns the index at which it is found. If the string is not found, -1 is returned. Provide a position to specify an index to start searching at. Example.
var s = "what is the difference";[[br]] if (s.indexOf('the')!=-1) print('the sentence contained "the"');
s.lastIndexOf(string strSearch, int nPosition=nLength) => int nIndex
Searches for strSearch backwards (from right to left) inside the string, and returns the index at which it is found. If the string is not found, -1 is returned. Provide a position to specify an index to start searching at.
s.match(RegExp re) => string strFound
Matches regular expression. Returns string matched if successful. If no match, returns null. Example.
var re=/(a)(b)/; print(s.replace(re, '$2$1')); //replaces ab with ba in the string.
s.replace(RegExp re, string strReplaceValue/function fnReplace) => string strResult
Use regular expression to replace in string. If regular expression is global, such as /a/g, then replaces all instances. Replacement string can contain $0, referring to matched string, or $1, referring to first match group and so on. Replacement function, if given, will be passed string, and is expected to return a string.
s.replace(string strFind, string strReplaceValue) => string strResult
Replace one instance of strFind with strReplaceValue. Note that if a regular expression is passed, behavior is different.
s.search(RegExp re) => int nIndex
Searches for regular expression in string. If found, returns position in string, otherwise returns -1.
s.slice(int nStart, int nEnd) => string strSlice
Return substring from nStart to nEnd. If start is negative, it is treated as (sourceLength+start) where sourceLength is the length of the string. If end is negative, it is treated as (sourceLength+end) where sourceLength is the length of the string.
s.split(string strSeperator) => array arSplit
Splits input string into an array of substrings. Call .split('') to split into characters. A RegExp object can also be passed. Example.
var s = "what is the difference"; var arWords = s.split(' '); //splits into array of words
s.startsWith(string strSmallerString) => bool bStartsWith
Tests if string starts with a certain substring. Use include('<std>') to import this function.
s.strip() => string strStripped
Removes whitespace from beginning and end of string, similarly to the traditional strip() or trim(). Use include('<std>') to import this function.
s.substring(int nStart, int nEnd=nLength) => array arSplit
Return substring of the input. If an end index is not provided, returns the string from the nth position to the end of the string. Example.
var s = "abcdefg"; var sSlice = s.substring(0,3); //abc
s.toLowerCase() => string strLower
Convert string to lower case.
s.toUpperCase() => string strUpper
Convert string to upper case.