private void executeAction() {

		index++;
		if (index == actions.size()) {
			return;
		}

		scriptVisualization.setSelectedIndex(index);
		scriptVisualization.ensureIndexIsVisible(index);

		DeviceCommandMessage d = actions.elementAt(index);
		if (d instanceof KeyCommandMessage) {
			KeyCommandMessage km = ((KeyCommandMessage) d);
			client.sendMessage(km);
			if (km.getKeyCommandType() == KeyCommandMessageType.KEY_DOWN) {
				executeAction();
			}
		} else if (d instanceof TouchCommandMessage) {
			TouchCommandMessage tm = ((TouchCommandMessage) d);
			client.sendMessage(tm);
			if (tm.getTouchCommandType() != TouchCommandMessageType.TOUCH_UP) {
				executeAction();
			}
		} else if (d instanceof ScriptCommandMessage) {
			ScriptCommandMessage sm = ((ScriptCommandMessage) d);
			if ((sm.getActionType() == ScriptCommandMessageType.SLEEP)
					|| (sm.getActionType() == ScriptCommandMessageType.PAUSE)) {
				executeAction();
			}
		}
	}