public class UIRobot
extends java.lang.Object
Vm.interceptSpecialKeys(new int[]{SpecialKeys.FIND}); Settings.deviceRobotSpecialKey = SpecialKeys.FIND;You should set it at the application's constructor. When this key is pressed, it opens a window with three options: record, playback and cancel. Clicking on the "record" button opens another window asking for the robot's name. Type the name and press "Start record" to start recording. Do the events smoothly and slowly. When done, press the special key again. Clicking in the playback button opens a screen with a list of recorded robots. After selecting the robots, press one of these buttons:
if (event.type == UIRobotEvent.ROBOT_FAILED || event.type == UIRobotEvent.ROBOT_SUCCEED) { try { File f = new File(Settings.appPath+"/robot.log",File.CREATE_EMPTY); String s = event.type == UIRobotEvent.ROBOT_FAILED ? "FAILED" : "SUCCEED"; f.writeBytes("Robot "+UIRobot.robotFileName+" "+s+". Running time: "+UIRobot.totalTime); f.close(); } catch (Exception e) {e.printStackTrace();} }
SpecialKeys
,
UIRobotEvent
Modifier and Type | Field and Description |
---|---|
static boolean |
abort
Set to true to abort the run of the current UIRobot.
|
static int |
IDLE |
static int |
PLAYBACK |
static int |
RECORDING |
static java.lang.String |
robotFileName
The filename of the running robot.
|
static int |
status |
static int |
totalTime
The amount of time since the robot started.
|
Constructor and Description |
---|
UIRobot()
Constructs a new UIRobot and opens the user interface.
|
UIRobot(java.lang.String robotFileName)
Constructs a new UIRobot and starts the playback of the given file.
|
Modifier and Type | Method and Description |
---|---|
void |
addUIRobotListener(UIRobotListener listener)
Adds a listener for UIRobot events.
|
void |
onEvent(int type,
int key,
int x,
int y,
int modifiers) |
void |
removeUIRobotListener(UIRobotListener listener)
Removes a listener for UIRobot events.
|
void |
stop() |
public static final int IDLE
public static final int RECORDING
public static final int PLAYBACK
public static int status
public static boolean abort
public static java.lang.String robotFileName
public static int totalTime
public UIRobot() throws java.lang.Exception
java.lang.Exception
public UIRobot(java.lang.String robotFileName) throws java.lang.Exception
java.lang.Exception
public void onEvent(int type, int key, int x, int y, int modifiers)
public void stop() throws java.lang.Exception
java.lang.Exception
public void addUIRobotListener(UIRobotListener listener)
UIRobotListener
public void removeUIRobotListener(UIRobotListener listener)
UIRobotListener