<<

Functions

Below are functions exclusive to Javauto. Many are designed to interact with the mouse, keyboard, or screen instead of just the system.

Note that these functions are all designed to make your life easier, especially with regards to emulating some AutoIt like functions that are verbose to re-write in Java, but this is not an exhaustive list of functions that you may use in your code. For the most part, Java is also acceptable.

For example, instead of this:

msgBox("Hello world");

You could write the java equivalent:

JOptionPane.showMessageDialog(null,"Hello world","",JOptionPane.PLAIN_MESSAGE);

One is just (quite) a bit more verbose.

The exceptions to this are user defined functions and class variables. Instead of writing these in Java you must use native user defined functions and global variables.


arrayAsList

Returns a fixed-size list backed by the specified Array.

arrayAsList( String[] array )

Parameters:

array This is the Array of strings by which the list will be backed.

Returns:

List<String> This method returns a list view of the specified Array.

Example:

//Returns a fixed-size list backed by the specified Array.
String[] strArr = {"each", "of", "these", "is", "an", "element"};
List<String> theList = arrayAsList(strArr);
print(theList.size()); 

arrayBinarySearch | byte

This method searches the specified Array of bytes for the specified value using the binary search algorithm.

arrayBinarySearch( byte[] a, byte key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

byte searchVal = 35;
byte arr[] = { 10, 12, 34, searchVal, 5 };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | char

This method searches the specified Array of chars for the specified value using the binary search algorithm.

arrayBinarySearch( char[] a, char key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

char searchVal = 'c';
char arr[] = { 'a', 'c', 'b', 'e', 'd' };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | double

This method searches the specified Array of doubles for the specified value using the binary search algorithm.

arrayBinarySearch( double[] a, double key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

double searchVal = 4.6;
double arr[] = { 5.4, 49.2, 9.2, 35.4, 4.6 };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | float

This method searches the specified Array of floats for the specified value using the binary search algorithm.

arrayBinarySearch( float[] a, float key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

float searchVal = 42.9f;
float arr[] = { 5.2f, 46.1f, 42.9f, 22.3f };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | int

This method searches the specified Array of int for the specified value using the binary search algorithm.

arrayBinarySearch( int[] a, int key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

int searchVal = 5;
int arr[] = { 30, 20, 5, 12, 55 };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | long

This method searches the specified Array of longs for the specified value using the binary search algorithm.

arrayBinarySearch( long[] a, long key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

long searchVal = 46464;
long arr[] = { 56, 46464, 3342, 232, 3445 };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayBinarySearch | short

This method searches the specified Array of shorts for the specified value using the binary search algorithm.

arrayBinarySearch( short[] a, short key )

Parameters:

a This is the Array to be searched.
key This is the value to be searched for.

Returns:

int The index of the search key, if it is contained in the Array, else it returns (-(insertion point) - 1). The insertion point is the point at which the key would be inserted into the Array: the index of the first element greater than the key, or a.length if all elements in the Array are less than the specified key.

Example:

short searchVal = 52;
short arr[] = { 5, 2, 15, 52, 10 };
int index = arrayBinarySearch(arr, searchVal);
print("The index of the search key is:" + index);

arrayCopyOf | boolean

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For all indices that are valid in both the original Array and the copy, the two Arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain false. Such indices will exist if and only if the specified length is greater than that of the original Array.

arrayCopyOf( boolean[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

boolean[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

boolean[] a1 = new boolean[] { true, false };
boolean[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | byte

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For all indices that are valid in both the original Array and the copy, the two Arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain (byte) 0.Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( byte[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

byte[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

byte[] a1 = new byte[] { 5, 62, 15 };
byte[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | char

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For all indices that are valid in both the original Array and the copy, the two Arrays will contain identical values. or any indices that are valid in the copy but not the original, the copy will contain '\\u000'. Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( char[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

char[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

char[] a1 = new char[] { 'p', 's', 'r' };
char[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | double

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For any indices that are valid in the copy but not the original, the copy will contain 0d .Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( double[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

double[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

double[] a1 = new double[] { 12.5, 3.2, 37.5 };
double[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | float

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For any indices that are valid in the copy but not the original, the copy will contain 0f .Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( float[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

float[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

float[] a1 = new float[] { 10f, 32f, 25f };
float[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | int

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For any indices that are valid in the copy but not the original, the copy will contain 0 .Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( int[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

int[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

int[] a1 = new int[] { 45, 32, 75 };
int[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | long

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For any indices that are valid in the copy but not the original, the copy will contain 0l .Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( long[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

long[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

long[] a1 = new long[] { 15, 10, 45 };
long[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arrayCopyOf | short

This method copies the specified Array, truncating or padding with false (if necessary) so the copy has the specified length. For any indices that are valid in the copy but not the original, the copy will contain (short) 0. Such indices will exist if and only if the specified length is greater than that of the original array.

arrayCopyOf( short[] original, int newLength )

Parameters:

original The Array to be copied.
newLength The length of the copy to be returned.

Returns:

short[] A copy of the original array, truncated or padded with false elements to obtain the specified length.

Example:

short[] a1 = new short[] { 15, 10, 45 };
short[] a2 = arrayCopyOf(a1, 4);
print("a2 size is:" + a2.length);

arraySort | byte

This method sorts the specified array of bytes into ascending numerical order.

arraySort( byte[] a )

Parameters:

a The array to be sorted.

Returns:

byte[] The sorted array.

Example:

byte[] a1 = { 10, 2, 7, 35 };
byte[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | char

This method sorts the specified array of chars into ascending numerical order.

arraySort( char[] a )

Parameters:

a The array to be sorted.

Returns:

char[] The sorted array.

Example:

char[] a1 = { 'r', 'q', 's', 'p' };
char[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | double

This method sorts the specified array of doubles into ascending numerical order.

arraySort( double[] a )

Parameters:

a The array to be sorted.

Returns:

double[] The sorted array.

Example:

double[] a1 = { 3.2, 1.2, 9.7 };
double[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | float

This method sorts the specified array of floats into ascending numerical order.

arraySort( float[] a )

Parameters:

a The array to be sorted.

Returns:

float[] The sorted array.

Example:

float[] a1 = { 3.2f, 1.2f, 9.7f };
float[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | int

This method sorts the specified array of int into ascending numerical order.

arraySort( int[] a )

Parameters:

a The array to be sorted.

Returns:

int[] The sorted array.

Example:

int[] a1 = { 2, 1, 9 };
int[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | long

This method sorts the specified array of longs into ascending numerical order.

arraySort( long[] a )

Parameters:

a The array to be sorted.

Returns:

long[] The sorted array.

Example:

long[] a1 = { 22, 10, 91 };
long[] a2 = arraySort(a1);
print(arrayToString(a2));

arraySort | short

This method sorts the specified array of shorts into ascending numerical order.

arraySort( short[] a )

Parameters:

a The array to be sorted.

Returns:

short[] The sorted array.

Example:

short[] a1 = { 22, 10, 91 };
short[] a2 = arraySort(a1);
print(arrayToString(a2));

arrayToString | boolean

This method returns a string representation of the contents of the specified boolean array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(boolean[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

boolean[] a1 = new boolean[] { true, false };
print(arrayToString(a1));

arrayToString | byte

This method returns a string representation of the contents of the specified byte array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(byte[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

byte[] a1 = new byte[] { 5, 62 };
print(arrayToString(a1));

arrayToString | char

This method returns a string representation of the contents of the specified char array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(char[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

char[] a1 = new char[] { 'p', 's' };
print(arrayToString(a1));

arrayToString | double

This method returns a string representation of the contents of the specified double array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(double[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

double a1[] = { 5.4, 49.2 };
print(arrayToString(a1));

arrayToString | float

This method returns a string representation of the contents of the specified float array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(float[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

float a1[] = { 5.2f, 46.1f };
print(arrayToString(a1));

arrayToString | int

This method returns a string representation of the contents of the specified int array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(int[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

int a1[] = { 5, 4 };
print(arrayToString(a1));

arrayToString | long

This method returns a string representation of the contents of the specified long array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(long[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

long a1[] = { 56, 46464 };
print(arrayToString(a1));

arrayToString | short

This method returns a string representation of the contents of the specified short array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).

arrayToString(short[] a)

Parameters:

a The array whose string representation to return.

Returns:

String A string representation of a.

Example:

short a1[] = { 5, 2 };
print(arrayToString(a1));

arrayEquals | boolean

This method returns true if the two specified arrays of booleans are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(boolean[] a, boolean[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

boolean[] a1 = new boolean[] { true, false };
boolean[] a2 = new boolean[] { true, false };
boolean[] a3 = new boolean[] { true, true };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | byte

This method returns true if the two specified arrays of bytes are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(byte[] a, byte[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

byte[] a1 = new byte[] { 5, 62 };
byte[] a2 = new byte[] { 5, 62 };
byte[] a3 = new byte[] { 5 };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | char

This method returns true if the two specified arrays of chars are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(char[] a, char[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

char[] a1 = new char[] { 'p', 's' };
char[] a2 = new char[] { 'p', 's' };
char[] a3 = new char[] { 'p', 'p' };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | double

This method returns true if the two specified arrays of doubles are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(double[] a, double[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

double[] a1 = { 5.4, 49.2 };
double[] a2 = { 5.4, 49.2 };
double[] a3 = { 5.4, 2.1 };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | float

This method returns true if the two specified arrays of floats are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(float[] a, float[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

float[] a1 = { 5.2f, 46.1f };
float[] a2 = { 5.2f, 46.1f };
float[] a3 = { 5.2f, 6.1f };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | int

This method returns true if the two specified arrays of int are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(int[] a, int[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

int[] a1 = { 1, 2 };
int[] a2 = { 1, 2 };
int[] a3 = { 0, 2 };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | long

This method returns true if the two specified arrays of longs are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(long[] a, long[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

long[] a1 = { 56, 46464 };
long[] a2 = { 56, 46464 };
long[] a3 = { 56, 46 };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | short

This method returns true if the two specified arrays of shorts are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(short[] a, short[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

short[] a1 = { 5, 2 };
short[] a2 = { 5, 2 };
short[] a3 = { 5, 5 };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayEquals | String

This method returns true if the two specified arrays of Strings are equal to one another.Two arrays are equal if they contain the same elements in the same order.Two array references are considered equal if both are null.

arrayEquals(String[] a, String[] a2) 

Parameters:

a The array to be tested for equality.
a2 The other array to be tested for equality.

Returns:

boolean true if the two arrays are equal, otherwise returns false.

Example:

String[] a1 = { "Pierre", "Fermat" };
String[] a2 = { "Pierre", "Fermat" };
String[] a3 = { "Evariste", "Galois" };
print(arrayEquals(a1, a2));
print(arrayEquals(a2, a3));

arrayToClip | String

Sends the contents of an array of strings to the clipboard.

arrayToClip( String[] a ) 


Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

String[] a1 = { "Pierre", "Fermat" };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | byte

Sends the contents of an array of bytes to the clipboard.

arrayToClip( byte[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

byte[] a1 = new byte[] { 5, 62 };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | boolean

Sends the contents of an array of booleans to the clipboard.

arrayToClip( boolean[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

boolean[] a1 = new boolean[] { true, false };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | char

Sends the contents of an array of chars to the clipboard.

arrayToClip( char[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

char[] a1 = new char[] { 'p', 's' };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | double

Sends the contents of an array of doubles to the clipboard.

arrayToClip( double[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

double a1[] = { 5.4, 49.2 };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | float

Sends the contents of an array of floats to the clipboard.

arrayToClip( float[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

float[] a1 = { 5.2f, 46.1f };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | int

Sends the contents of an array of int to the clipboard.

arrayToClip( int[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

int[] a1 = { 5, 4 };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | long

Sends the contents of an array of longs to the clipboard.

arrayToClip( long[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

long[] a1 = { 56, 46464 };
arrayToClip(a1);
print(clipboardGet());

arrayToClip | short

Sends the contents of an array of shorts to the clipboard.

arrayToClip( short[] a ) 

Parameters:

a Array to copy to clipboard.

Returns:

void

Example:

short[] a1 = { 5, 2 };
arrayToClip(a1);
print(clipboardGet());

clipboardGet

Get the contents of the clip board (as string).

clipboardGet()

Parameters: none

Returns:

String The clip board contents as a string. Returns null if the data inside the clip board cannot be read to a string.

Example:

//add something to the clipboard
String clip = "put me in the clipboard!";
clipboardPut(clip);

//retrieve clipboard contents
String clipContents = clipboardGet();
msgBox(clipContents);

clipboardPut

Put a string in the system clipboard. On Ubuntu Linux the way the clipboard is handled only allows information in the clipboard to be accessible while the application that put it there is running.

clipboardPut(String s)

Parameters:

s String data to put in the clip board.

Returns: void

Example:

//add something to the clipboard
String clip = "put me in the clipboard!";
clipboardPut(clip);

//retrieve clipboard contents
String clipContents = clipboardGet();
msgBox(clipContents);

cursorGetPos

Get the current position of the mouse cursor in an integer array.

cursorGetPos()

Parameters: none

Returns:

int[] Integer array formatted like [x position, y position].

Example:

//get the cursor position
int[] cursorPos = cursorGetPos();
msgBox("Cursor Position is (" + cursorPos[0] + "," + cursorPos[1] + ")");

exec

Execute a shell command and return the output. This will not display a visible process and it will wait for the command to finish before continuing. On Windows systems (the os can be checked with the {@link OS_SYSTEM} constant) the command string must be of the format "cmd /c command".

exec( String cmd )

Parameters:

cmd The command to execute.

Returns:

String The output of the command.

Example:

//attempt to guess platform and then run the dir or the ls command depending on windows/other
if (SYSTEM_OS.toLowerCase().contains("windows")) {
	String cmdOutPut = exec("cmd /c dir"); 
	print(cmdOutPut);
} else {
	String cmdOutPut = exec("ls"); 
	print(cmdOutPut);
}

exit

Terminates the currently running Java Virtual Machine. The argument serves as a status code. This code can be used by Windows or the DOS variable %ERRORLEVEL%. On *nix to check the exit code we can simply print the $? special variable in bash. This variable will print the exit code of the last run command.

exit( int code )

Parameters:

code [optional] Integer that sets the script's return code.(The default is 0.) Exit code is:
  • 0 when execution went fine
  • 1, -1, whatever != 0 when some error occurred

Returns: void

Example:

//Terminate script if no command-line arguments
if(args.length  == 0){ 
     exit(1);
}
              

fileAppend

Append data to a file. If the file does not exist it will be created.

fileAppend( String fPath, String data )

Parameters:

fPath The path of the file to which we are appending data.
data The data to be appended to the file.

Returns:

boolean If appending to the file failed false will be returned. Otherwise will return true.

Example:

Example Code

fileCreate

Create a file. Similar to the unix touch command.

fileCreate(String fPath)

Parameters:

fPath Path of file to be created.

Returns: void

Example:

Example Code

fileDelete

Delete a file. This will not work on a directory.

fileDelete(String fPath)

Parameters:

fPath Path of the file to delete.

Returns: void

Example:

Example Code

fileExists

Check if a file or directory exists.

fileExists(String fPath)

Parameters:

fPath Path of the file or directory to check.

Returns:

boolean Will return true if the file or directory exists, otherwise returns false.

Example:

Example Code

fileGetName

Get the base name of a file, including its extension.

fileGetName(String fPath)

Parameters:

fPath Path of the file.

Returns:

String Name of the file (including extension).

Example:

Example Code

fileGetPath

Get the full file path of a specific file or directory.

fileGetPath(String fPath)

Parameters:

fPath Path of the file.

Returns:

String The full (absolute) path of the file or directory.

Example:

Example Code

fileList

Get a list of file names in a directory as an array.

fileList( String dir )

Parameters:

dir Directory to list files from.

Returns:

String[] String array of file names.

Example:

// get all the files in the working dir
String[] files = fileList(WORKING_DIR);

// list the files
for (String file : files)
print(file);

fileRead

Read the contents of a file to a string.

fileRead( String fPath )

Parameters:

fPath Path of the file to read.

Returns:

String The contents of the file as a string.

Example:

// write data to a test file
String data = inputBox("Enter some data to write");
boolean success = fileWrite("test.txt", data);
if (!success) {
print("There was an error writing to file.");
System.exit(1);
}

// read data from the file String test = fileRead("test.txt"); msgBox(test); // display the data

fileWrite

Write data to a file -- this will overwrite the file. If the file does not exist it will be created.

fileWrite( String fPath, String data )

Parameters:

fPath Path of the file to write to.
data Data to write to the file as a string.

Returns:

boolean Returns false if the file write failed. Otherwise returns true.

Example:

// write data to a test file
String data = inputBox("Enter some data to write");
boolean success = fileWrite("test.txt", data);
if (!success) {
print("There was an error writing to file.");
System.exit(1);
}

// read data from the file String test = fileRead("test.txt"); msgBox(test); // display the data

getEnv

Retrieves an environment variable.

getEnv( String var )

Parameters:

var Name of the environment variable to get such as "JAVA_HOME" or "PATH".

Returns:

String The value of the environment variable specified by variable, or an empty String if the environment variable is not found.

Example:

print(getEnv("PATH"));

getEnv

Retrieve all environment variables along with their values.

getEnv()

Parameters:

Returns:

String ll environment variables along with their values. For example: "Var1=Value, Var2=Value"

Example:

print(getEnv());

getDateTime

Get the system date and time in yyyy/MM/dd HH:mm:ss format.

getDateTime()

Parameters: none

Returns:

String The date and time as a string in yyyy/MM/dd HH:mm:ss format.

Example:

print(getDateTime());
// output: 2015/01/05 15:59:25

getFlaggedArg

Get the value of a flagged argument. So if the program is executed like java program -v --file aFile.txt -o outFile.txt getFlaggedArg(args, "-f|--file") would return aFile.txt.

getFlaggedArg(String[] args, String flag)

Parameters:

args The String[] args from the main function. Pass them in by just saying args.
flag The flags to get values from, separated by | like -f|--file.

Returns:

String The argument directly after the detected flag.

Example:

Example Code

getMilliTime

Gets the current time in milliseconds. There are 1000 milliseconds in 1 second, so divide by 1000 to find seconds.

getMilliTime()

Parameters: none

Returns:

long This method returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC(coordinated universal time).

Example:

Example Code

getNanoTime

Gets the current value from the most precise system timer on a computer, in nanoseconds. It returns nanoseconds since some fixed but arbitrary time. This fixed time could even be in the future, resulting in a negative value. getNanoTime should be used to measure the time between events, not as a wall clock.
There are 1,000,000,000 nanoseconds in a second, and 1,000,000 nanoseconds in a millisecond.

getNanoTime()

Parameters: none

Returns:

long The current value of the system timer, in nanoseconds.

Example:

Example Code

getPage

Get the source of a web page as HTML.

getPage(String url)

Parameters:

url The page to fetch.

Returns:

String The page source (HTML) as a string.

Example:

Example Code

getSpeed

Get the current speed. The speed controls how quickly mouse and keyboard actions happen. The default speed is .95 (95%). A speed of 1.00 (100%) makes mouse and keyboard actions instant.

getSpeed()

Parameters: none

Returns:

double The speed as a decimal from 0.00 to 1.00.

Example:

Example Code

httpGet

Send a HTTP GET request to a URL.

httpGet(String url)

Parameters:

url The URL to query, including the get parameters.

Returns:

String Page response as HTML.

Example:

Example Code

httpPost

Send a HTTP POST request to a given URL with the specified parameters.

httpPost(String postUrl, String[][] parameters)

Parameters:

postUrl URL to send the post request to.
parameters Post parameters to send to URL. Parameters must be defined in a two dimesional array like [ [key, value], [key, value], [key, value] ].

Returns:

String Page response as HTML.

Example:

Example Code

input

Get user input from the console.

input()
input( String prompt )

Parameters:

prompt The prompt to display to the user.

Returns:

String The user's response.

Example:

// get input from command line and print it
String userResponse = input("Enter your name: "); // get user input from the console
String greeting = "Hello " + userResponse + ", it's nice to meet you.";
print(greeting);

inputBox

Display an input dialog box to the user.

inputBox( String Text )
inputBox( String Text, String Title)

Parameters:

Text Text to be displayed in the dialog box.
Title Title of the dialog box.

Returns:

String User's input as a string.

Example:

//get user input
String input = inputBox("Enter something: ", "Input Box");
print("You said: " + input);

inputList

Show a dialog allowing the user to choose from a drop-down list of items.

inputList( String Text, String Title, String[] Choices )
inputList( String Text, String Title, String[] Choices, int Default )

Parameters:

Text Text to be displayed in the dialog box.
Title Title of the dialog box.
Choices The options in the drop-down as a string array.
Default The index of the default option in the Choices array.

Returns:

String The user's choice as a string.

Example:

//open a website based on user choice
String[] inputListObjects = {"https://www.google.com/", "http://www.yahoo.com/", "http://www.bing.com/", "http://www.defaultChoice.com/"};
String inputListResult = inputList( "Choose a website: ", "Choose one", inputListObjects, inputListObjects[3] );
open(inputListResult); 

inputPassword

Get a password from the user. Displays a dialog box where the input is masked.

inputPassword ( String Text )
inputPassword ( String Text, String Title )
inputPassword ( String Text, String Title, String Okay )

Parameters:

Text Text to be displayed in the dialog box.
Title Title of the dialog box.
Okay text of the okay button, eg. okay, submit, go, login, etc.

Returns:

String The user's input

Example:

//get password input
String passwordResult = inputPassword("Input a password: "); 
print("Your password is: " + passwordResult);

intGetRGB

Get the RGB values of an integer color value.

intGetRGB(int i)

Parameters:

i The integer value of the color.

Returns:

int[] An array with three values: [red, green, blue].

Example:

Example Code

intGetRandom

Get a random integer between two inclusive values.

intGetRandom( int min, int max )

Parameters:

min The minimum integer value to be returned (inclusive).
max The minimum integer value to be returned (inclusive).

Returns:

int A random integer between min and max.

Example:

//get a random number between 0 and 5
int random = intGetRandom(0,5); // could return 0, 1, 2, 3, 4, or 5
print(random); 

//move mouse to random coordinates
int randX = intGetRandom(0, SCREEN_WIDTH);
int randY = intGetRandom(0, SCREEN_HEIGHT);
mouseMove(randX, randY);

isDirectory

Check if a path is a directory.

isDirectory(String fPath)

Parameters:

fPath Path to evaluate.

Returns:

boolean True if directory, false if not.

Example:

Example Code

isFile

Returns true for a file but not for a directory (or a non-existent file).

isFile(String fPath)

Parameters:

fPath Path to evaluate.

Returns:

boolean Returns true if fPath is a file, otherwise returns false.

Example:

Example Code

isFlagged

Check if a flag is present within the command line arguments.

isFlagged(String[] args, String flag)

Parameters:

args The String[] args from the main function. Pass them in by just saying args.
flag The flag(s) to check for, separate possible values with a pipe | For instance -h|--help could match either one.

Returns:

boolean True or false based on whether the flag is present.

Example:

Example Code

join

Join a string array into a string with a delimeter.

join(String joinString, String[] strArray)

Parameters:

joinString The delimeter with which to join the string array.
strArray The array to join.

Returns:

String The array as a string with the delimeter between each index.

Example:

// create a string array
String[] pets = {"cat", "dog", "elephant", "fish"};

// join it with various delimeters
print( join(" ", pets) );
print( join(", ", pets) );
print( join("\n", pets) );

Output:

cat dog elephant fish
cat, dog, elephant, fish
cat
dog
elephant
fish

keyCombo

Send a key combination such as Ctrl + Alt + Delete. The keys must be passed in as a string array.

keyCombo(int... keys)
keyCombo(String... keys)

Parameters:

keys The key combination to be executed as a String array. The keys in this array must be in order and may contain special keys. The array can be of any size.

Returns: void

Example:

Example Code

keyDown

Hold down a key until {@link keyUp} is called on the same key. If keyUp is not called the key will become "stuck." Special keys can also be used here.

keyDown( int i )
keyDown( String str )

Parameters:

str The key that will be held down. If there are multiple letters or keys specified only the first will be held down.

Returns: void

Example:

Example Code

keyPress

Simulate the press and release of a single key. Special keys can be used here.

keyPress( int i )
keyPress( String s)

Parameters:

s The single key to press or release. If more than one key is specified only one key will be pressed.

Returns: void

Example:

Example Code

keyUp

Release a key that has been held down. Special keys can also be used here.

keyUp( int i )
keyUp( String str )

Parameters:

str The single key that will be released. If more than one key is specified only the first will be released.

Returns: void

Example:

Example Code

mkDir

Create a directory.

mkDir(String dirName)

Parameters:

dirName The name of the directory to create. If the directory already exists no action will be taken.

Returns: void

Example:

Example Code

mouseClick

Perform a mouse click.

mouseClick( String button )
mouseClick( String button, int x, int y )

Parameters:

button either "left", "right", or "middle"
x The X value of the coordinate that will be clicked on.
y The Y value of the coordinate that willl be clicked on.

Returns: void

Example:

Example Code

mouseClickDrag

Click and drag the mouse from one coordinate to another.

mouseClickDrag( String button, int x1, int y1, int x2, int y2 )

Parameters:

button The mouse button to simulate. This value must be either "left", "right", or "middle".
x1 First coordinate X value.
y1 First coordinate Y value.
x2 Second coordinate X value.
y2 Second coordinate Y value.

Returns: void

Example:

//click and drag the mouse from one location to another
mouseClickDrag("left", 500, 500, 50, 50);

mouseDown

Press down a mouse button. If {@link mouseUp} is not called the mouse will be stuck down.

mouseDown( String button )
mouseDown( String button, int x, int y )

Parameters:

button The mouse button to simulate. This value must be either "left", "right", or "middle".
x The X value of the coordinate that will be clicked on.
y The Y value of the coordinate that will be clicked on.

Returns: void

Example:

//hold down the left mouse button for two seconds
mouseDown("left"); //press the button
sleep(2000);
mouseUp("left"); //release the button

mouseMove

Move the mouse cursor to a certain position. The speed of the mouse movement can be set with {@link setSpeed}. Note that mouse coordinates can be found with the Javauto Helper.

mouseMove( int xFinal, int yFinal)

Parameters:

xFinal The X value of the coordinate to move the mouse to.
yFinal The Y value of the coordinate to move the mouse to.

Returns: void

Example:

//move the mouse to coordinates
mouseMove(50, 50);

mouseScrollDown

Scroll the mouse wheel down once.

mouseScrollDown()

Parameters: none

Returns: void

Example:

mouseScrollDown(); //scroll down
sleep(1000); //wait one second
mouseScrollUp(); //scroll up

mouseScrollUp

Scroll the mouse wheel up once.

mouseScrollUp()

Parameters: none

Returns: void

Example:

mouseScrollDown(); //scroll down
sleep(1000); //wait one second
mouseScrollUp(); //scroll up

mouseUp

Release a pressed mouse button.

mouseUp( String button )

Parameters:

button The mouse button to simulate. This value must be either "left", "right", or "middle".

Returns: void

Example:

// hold down the left mouse button for two seconds
mouseDown("left"); //press the button
sleep(2000);
mouseUp("left"); //release the button

msgBox

Display a message dialog box until the user closes it or it times out.

msgBox( String Text )
msgBox( String Text, String Title )
msgBox(String Text, String Title, int Timeout)

Parameters:

Text Text to be displayed as the prompt in the dialog box.
Title Title of the dialog window.
Timeout Time (in milliseconds) to wait until until the window times out automatically.

Returns: void

Example:

msgBox("This window will be active for five seconds.", "Timed msgBox", 5000);
msgBox("This window will be active until it is closed.", "Standard msgBox");

open

Open a file or URL in the default program. (This will be the default browser if it's a URL.)

open( String path )

Parameters:

path The URL or file to open. URLs must begin with http:// or https://

Returns:

boolean Returns true on success. Returns false on failure.

Example:

// open google
open("https://www.google.com/");

// open a screenshot we take
String fileName = "screen.png";
screenShot(fileName);
open(fileName);

// delete the screenshot after giving it a few seconds to open
sleep(3000);
fileDelete(fileName);

optionsBox

Display a message box with custom button options.

optionsBox(String Text, String Title, String[] buttons)
optionsBox(String Text, String Title, String[] buttons, String defaultButton)

Parameters:

Text Text to display as a prompt.
Title Title of the dialog window.
buttons String array of button names to be available.
defaultButton The default button to be selected when "Enter" is pressed. defaultButton should be the text of the desired default button.

Returns:

int The index of selected button within the buttons array.

Example:

// display a message box with custom buttons
String[] buttons = {"Yes", "No", "Maybe so"};
int i = optionsBox("Allow the mouse to move?", "Response Required", buttons, buttons[0]);

// manage the result
if (i == 0) // if they selected the first button (yes)
mouseMove(50, 50);
else if (i == 1) // if they selected the second button (no)
print("Not moving the mouse.");
else if (i == 2) // if they selected the third button (maybe so)
if ( intGetRandom(0,1) == 0 ) // construct a 50-50 chance that we move the mouse
mouseMove(50, 50);
else
print("Mouse not moved.");

pixelGetColor

Get the color of a certain pixel as an integer.

pixelGetColor( int x, int y )

Parameters:

x X coordinate of pixel.
y Y coordinate of pixel.

Returns:

int The integer representation of the pixel's color.

Example:

Example Code

pixelSearch

Search for the coordinates of a pixel of a certain color within an area. This will return the coordinates of the first pixel found within the area that matches the search color.

pixelSearch ( int colorInt )
pixelSearch ( int colorInt, int x1, int y1, int x2, int y2 )
pixelSearch ( int colorInt, int x1, int y1, int x2, int y2, int speed )

Parameters:

colorInt Integer representation of the color to search for.
x1 X value of top left coordinate.
y1 Y value of top left coordinate.
x2 X value of bottom right coordinate.
y2 Y value of bottom right coordinate.
speed A value of 1-5 to describe how fast to search. A speed of 2 searches twice as fast as speed 1 except it only checks every other pixel, which is fine if the color you're trying to find is more than two pixels wide.

Returns:

int[] If the color is found coordinates are returned in an int array formatted like: [x, y]. If the color is not found it will return [-1,-1]. If there is an error executing the search it will return [-3, -3].

Example:

Example Code

print

Print to the terminal.

print( String s )
print( Object obj )
print( long l )
print( int i )
print( float f )
print( double d )
print( char[] s )
print( char c )
print( boolean b )

Parameters:

obj Object to print

Returns: void

Example:

Example Code

rgbGetInt

Get an integer representation of a color based on R,G,B values.

rgbGetInt(int r, int g, int b)

Parameters:

r r value.
g g value.
b b value.

Returns:

int The integer representation of the color.

Example:

Example Code

rmDir

Delete a directory and its contents.

rmDir(String filePath)

Parameters: none

Returns: void

Example:

Example Code

screenShot

Take a screenshot and save to a PNG file.

screenShot( String fileName )
screenShot( String fileName, int x1, int y1, int x2, int y2 )

Parameters:

fileName Filename to save the PNG screenshot to.
x1 X value of top left coordinate.
y1 Y value of top left coordinate.
x2 X value of bottom right coordinate.
y2 Y value of bottom right coordinate.

Returns: void

Example:

// take a screenshot of the whole screen and save to myScreenShot.png
screenShot("myScreenShot.png");

// take a partial screenshot from coordinates (0,0) to (100, 100)
screenShot("anotherOne.png", 0,0, 100, 100);

// open the screenshots
open("myScreenShot.png");
open("anotherOne.png");

send

Simulate keyboard input by "typing" the contents of str. Special keys can also be typed. The speed at which this typing occurs can be set with {@link setSpeed}.

send(String str)

Parameters:

str The string to type, one letter (or special key) at a time.

Returns: void

Example:

Example Code

setSpeed

Set the current speed. The speed controls how quickly mouse and keyboard actions happen. The default speed is .95 (95%). A speed of 1.00 (100%) makes mouse and keyboard actions instant.

setSpeed(double spd)

Parameters:

spd The new speed as a double. This value must be between 0.00 and 1.00, if it isn't no action will be taken. A speed of 1.00 will make mouse and keyboard actions instant.

Returns: void

Example:

Example Code

sleep

Delay execution for an amount of milliseconds (1000 milliseconds = 1 second).

sleep( int milliseconds )

Parameters:

milliseconds Time to delay; must be between 0 and 60,000ms. Only takes integer values.

Returns: void

Example:

print("About to sleep for 1 second...");
sleep(1000);
print("All done.");

toChar

Convert to a char.

toChar( char c )
toChar( String s )

Parameters: none

Returns:

char none

Example:

String s = "s";
char c = toChar(s);

toDouble

Convert to a double.

toDouble( byte b )
toDouble( double d )
toDouble( float f )
toDouble( short s )
toDouble( long l )
toDouble( int i )
toDouble( boolean b )
toDouble( char c )
toDouble( String s )

Parameters: none

Returns:

double none

Example:

int i = 10;
double d = toDouble(i);
float f = toFloat(i);

print( i/3 ); // prints 3
print( d/3 ); // prints 3.3333333333333335
print( f/3 ); // print 3.3333333

toFloat

Convert to a float.

toFloat( byte b )
toFloat( double d )
toFloat( float f )
toFloat( short s )
toFloat( long l )
toFloat( int i )
toFloat( boolean b )
toFloat( char c )
toFloat( String s )

Parameters: none

Returns:

float none

Example:

int i = 10;
double d = toDouble(i);
float f = toFloat(i);

print( i/3 ); // prints 3
print( d/3 ); // prints 3.3333333333333335
print( f/3 ); // print 3.3333333

toInt

Convert to an int.

toInt( byte b )
toInt( double d )
toInt( float f )
toInt( short s )
toInt( long l )
toInt( int i )
toInt( boolean b )
toInt( char c )
toInt( String s )

Parameters: none

Returns:

int none

Example:

String aNumber = "100";
int n = toInt(aNumber);
print( n/2 ); // prints 50

toString

Convert to string.

toString( byte b )
toString( double d )
toString( float f )
toString( short s )
toString( long l )
toString( int i )
toString( boolean b )
toString( char c )
toString( String s )

Parameters: none

Returns:

String none

Example:

int i = 10;
double d = toInt(i);

String result = toString(i/3); // result now contains "3"
result = toString(d/3); // result now contains "3.3333333333333335"