public class ApplicationHandler
extends java.lang.Object
Applications.| Modifier and Type | Field and Description |
|---|---|
private Application[] |
appsList
List of all Applications, obtained from config file.
|
private java.lang.String |
config
Path to and name of config file.
|
private int |
currApp
The window id of the currently focused Application.
|
private InteractionHandler |
ih
InputHandler to generate dummy input.
|
private java.lang.String |
osName
Operating system, not currently used.
|
private ConfigHandler |
reader
ConfigHandler to retrieve info from the config file.
|
| Constructor and Description |
|---|
ApplicationHandler(java.lang.String config)
Object for interacting with Applications.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(int index)
Closes the Application at the specified index.
|
void |
close(java.lang.String name)
Closes the Application with the specified name.
|
void |
focus(int index)
Focuses and raises the Application at index
index. |
void |
focus(java.lang.String name)
Focuses and raises the Application with name
name. |
private int |
getCurrentApp(boolean check)
Gets the id of the currently focused application.
|
private int |
getWindowFocus()
Gets the id of the currently focused application.
|
private void |
initAppsList()
Initialises all objects in
appsList to null. |
boolean |
isApplication(java.lang.String name)
Returns true if an Application with name
name is specified in the config file. |
boolean |
isOpen(int index)
True if specified Application is open.
|
boolean |
isOpen(java.lang.String name)
True if specified Application is open.
|
void |
leftClick(java.lang.String pointName)
Wrapper for the InteractionHandler method leftClick.
|
void |
leftClickI(int pointIndex)
Wrapper for the InteractionHandler method leftClick.
|
void |
mouseWheelClick(java.lang.String pointName)
Wrapper for the InteractionHandler method mouseWheelClick.
|
void |
mouseWheelClickI(int pointIndex)
Wrapper for the InteractionHandler method mouseWheelClick.
|
void |
open(int index)
Opens the Application at index
index. |
void |
open(java.lang.String name)
Opens application with name
name. |
void |
pressDown()
Wrapper for the InteractionHandler method pressDown.
|
void |
pressLeft()
Wrapper for the InteractionHandler method pressLeft.
|
void |
pressRight()
Wrapper for the InteractionHandler method pressRight.
|
void |
pressUp()
Wrapper for the InteractionHandler method pressUp.
|
void |
rightClick(java.lang.String pointName)
Wrapper for the InteractionHandler method rightClick.
|
void |
rightClickI(int pointIndex)
Wrapper for the InteractionHandler method rightClick.
|
void |
typeInBox(java.lang.String pointName,
java.lang.String t,
boolean ret)
Wrapper for the InteractionHandler method typeInArea.
|
void |
typeInBoxI(int pointIndex,
java.lang.String t,
boolean ret)
Wrapper for the InteractionHandler method typeInArea.
|
private int |
windowSearch(java.lang.String search)
Searches for a window with
search in its title. |
private java.lang.String osName
private java.lang.String config
private ConfigHandler reader
private InteractionHandler ih
private Application[] appsList
private int currApp
public ApplicationHandler(java.lang.String config)
Used for opening and controlling all Applications specified in config file.
config - Path to config file.ConfigHandler,
Applicationprivate int windowSearch(java.lang.String search)
search in its title.
Native method to return the window id of
a window that has the String search
in its title.
search - The string to search for.private int getWindowFocus()
public void open(int index)
index.
If the specified Application is already open, it focuses it, otherwise it opens and focuses it.
index - Index of Application to be opened.open(String name)public void open(java.lang.String name)
name.
Gets the index of the Application with name name
and calls open(int index).
name - Name of Application to be opened.Application,
open(int index)public void focus(int index)
index.index - Index of Application to focus.public void focus(java.lang.String name)
name.
Gets the index of the Application with name name
and calls focus(int index).
name - Name of Application to focus.public boolean isOpen(int index)
index - Index of Application to be checked.public boolean isOpen(java.lang.String name)
name - Name of Application to be checked.public void close(int index)
index - Index of Application to close.public void close(java.lang.String name)
name - Name of Application to close.public boolean isApplication(java.lang.String name)
name is specified in the config file.name - Name of Application to search for .public void typeInBoxI(int pointIndex,
java.lang.String t,
boolean ret)
pointIndex - Point to click on.t - Text to type.ret - True if enter/return should be pressed after t is typed.InteractionHandler,
InteractionHandler.typeInArea(java.awt.Point, String, boolean)public void typeInBox(java.lang.String pointName,
java.lang.String t,
boolean ret)
pointName - Name of point to click on.t - Text to type.ret - True if enter/return should be pressed after t is typed.InteractionHandler,
InteractionHandler.typeInArea(java.awt.Point, String, boolean)public void leftClickI(int pointIndex)
pointIndex - Point to click on.InteractionHandler,
InteractionHandler.leftClick(java.awt.Point)public void leftClick(java.lang.String pointName)
pointName - Name of point to click on.InteractionHandler,
InteractionHandler.leftClick(java.awt.Point)public void rightClickI(int pointIndex)
pointIndex - Point to click on.InteractionHandler,
InteractionHandler.rightClick(java.awt.Point)public void rightClick(java.lang.String pointName)
pointName - Name of point to click on.InteractionHandler,
InteractionHandler.rightClick(java.awt.Point)public void mouseWheelClickI(int pointIndex)
pointIndex - Point to click on.InteractionHandler,
InteractionHandler.mouseWheelClick(java.awt.Point)public void mouseWheelClick(java.lang.String pointName)
pointName - Name of point to click on.InteractionHandler,
InteractionHandler.mouseWheelClick(java.awt.Point)public void pressUp()
public void pressDown()
public void pressLeft()
public void pressRight()
private int getCurrentApp(boolean check)
Gets the window id of the currently focused application.
check should be true if the value retrieved is
not expected to be different from currApp,
that is, when no Application has been closed. If an Application
has just been closed and currApp needs to be
updated then check should be false.
Returns the index of the focused Application or -1 if it's
not specified in the config file.
check - True if the value of currApp is not expected to be differentApplication or -1 if it's not specified in config fileApplication,
ApplicationHandler,
currAppprivate void initAppsList()
appsList to null.