-
Notifications
You must be signed in to change notification settings - Fork 0
Programmer's Guide
Getting set up is simple. Just download the [latest release] (https://github.com/jackoconnor/JGUII/releases) in the jar format.
For the sake of this guide, eclipse will be used for specifics (such as adding the jar to the build path) but there are very few specifics.
- In eclipse, right click on your project, hover over build path and select configure build path.
- Select the "Libraries" tab.
- Click "Add External JARs..."
- Select the jar.
- Click OK
In order to use JGUII you require a config file which contains information about the applications you will be controlling with JGUII. This can easily be generated with [JGUII-Config-Generator] (https://github.com/jackoconnor/JGUII-Config-Generator). All instructions on how to use this tool are at that link.
For general use of the JGUII library, you will only require one object ApplicationHandler.
It manipulates all the Applications for you. All details about it can be found in the [Javadoc.] (http://jackoconnor.github.io/JGUII/com/joc/jguii/ApplicationHandler.html) It can be instantiated as follows:
ApplicationHandler ah = new ApplicationHandler(config);
Where 'config' is a 'String' containing the absolute path to the config file. For example, "/home/user/Desktop/config.ini"
Now to open firefox all you have to do is:
ah.open("firefox");
Provided that firefox is defined in your config file and is called "firefox". BEWARE if you do not use EXACTLY the same string, this will not work. This will start firefox and focus it if it is not already running and if it is already running, it will just focus it.
To close firefox:
ah.close("firefox");
And to focus firefox:
ah.focus("firefox");
Due to the use of the config file, you can accomplish a massive amount in very few lines of code. For all types of input, the currently focused application will be used so its a good idea to call ah.focus("Application") before calling any of the dummy input functions discussed below.
If you have named a point "search" then to left click that point:
ah.leftClick("search");
OR
ah.leftClickI(int pointIndex);
The first example uses the name specified in the config file to identify the point, which is of type String. (Once again it must EXACTLY match the string in the config file.
The second example uses the index of the point specified in the config file to identify the point. Please note the 'I' after the standard function name for index.
The following functions can be uses in the same manner:
Right Click:
ah.rightClick(String pointName);
OR
ah.rightClickI(int point_Index);
Mouse Wheel Click:
ah.mouseWheelClick(String pointName);
OR
ah.mouseWheelClickI(int pointIndex);
###Keyboard Input Keyboard input consists of automating the process of typing strings and typing in a certain area/field (a point is defined for that area/field which is then clicked (to focus it) and then the string is entered).
To type "Hello world!" in a field who's point is named searchbar:
ah.typeInBox("searchbar", "Hello world!", false);
OR
ah.typeInBoxI(int point_index, "Hello world!", false);
The first example uses the name specified in the config file to identify the point, which is of type String. (Once again it must EXACTLY match the string in the config file.
The second example uses the index of the point specified in the config file to identify the point. Please note the 'I' after the standard function name for index.
Apart from that the two functions are identical. The second argument is the string to be typed and the final argument is a boolean specifying whether or not enter or return should be typed after the the string is typed. So if true, enter/return will be pressed, if false, it won't be.