我对数组不太好。在下面的代码中有两种方法从两个2D数组中获取数据。第一种方法COMBINATION正常工作。但第二种方法没有。
我在阵列声明???
下面的方法从数组中获取KeyEvent&执行Keypress& keyRelease根据数组中的KeyEvents
例如:
Combination.UNICODE_COPY, KeyEvent.VK_CONTROL, KeyEvent.VK_C
上面的行按CTRL + C.它执行复制功能。
我认为在第二种方法中我传递了3个KeyEvents。这是一个问题???
private static final int[][] COMBINATION = {
{
Combination.UNICODE_CUT, KeyEvent.VK_CONTROL, KeyEvent.VK_X
}, {
Combination.UNICODE_COPY, KeyEvent.VK_CONTROL, KeyEvent.VK_C
}, {
Combination.UNICODE_PASTE, KeyEvent.VK_CONTROL, KeyEvent.VK_V
}
};
private static final int[][] COMBINATIONS = {
{
Combinations.UNICODE_TASK, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_DELETE
}
};
private void keyboardCombination(Combination action)
{
boolean exception = false;
for (int i = 0; i < COMBINATION.length; i++)
{
if (action.unicode == COMBINATION[i][0])
{
exception = true;
this.application.getRobot().keyPress(COMBINATION[i][1]);
this.application.getRobot().keyPress(COMBINATION[i][2]);
// this.application.getRobot().keyPress(COMBINATION[i][3]);
this.application.getRobot().keyRelease(COMBINATION[i][1]);
this.application.getRobot().keyRelease(COMBINATION[i][2]);
// this.application.getRobot().keyRelease(COMBINATION[i][3]);
break;
}
}
if (!exception)
{
pressUnicode(this.application.getRobot(), action.unicode);
}
}
private void keyboardCombinations(Combinations action)
{
boolean exception = false;
for (int i = 0; i < COMBINATIONS.length; i++)
{
if (action.unicode == COMBINATIONS[i][0])
{
exception = true;
this.application.getRobot().keyPress(COMBINATIONS[i][1]);
this.application.getRobot().keyPress(COMBINATIONS[i][2]);
this.application.getRobot().keyPress(COMBINATIONS[i][3]);
this.application.getRobot().keyRelease(COMBINATIONS[i][1]);
this.application.getRobot().keyRelease(COMBINATIONS[i][2]);
this.application.getRobot().keyRelease(COMBINATIONS[i][3]);
break;
}
}
if (!exception)
{
pressUnicode(this.application.getRobot(), action.unicode);
}
}
组合
public class Combinations extends ControllerDroidAction
{
public static final int UNICODE_TASK = 40;
public int unicode;
public Combinations(int unicode)
{
this.unicode = unicode;
}
public static Combinations parse(DataInputStream dis) throws IOException
{
int unicode = dis.readInt();
return new Combinations(unicode);
}
public void toDataOutputStream(DataOutputStream dos) throws IOException
{
dos.writeByte(COMBINATIONS);
dos.writeInt(this.unicode);
}
}