Any idea how to send key combinations, like Ctrl + A?

Hi,

I’m trying to send key combinations to my app, such as CTRL + A, to do Select All and am having no luck. Does any have any experience of this?

I have tried lots of methods, such as:

Actions builder = new Actions(driver);
builder.KeyDown(Keys.Control).SendKeys(“a”).KeyUp(Keys.Control).Build().Perform();

and

((AndroidDriver)driver).KeyEvent(KEYCODE_CTRL_LEFT, ;
((AndroidDriver)driver).KeyEvent(KEYCODE_A, AndroidKeyMetastate.Meta_Ctrl_Left_On);

I am using Appium 1.2.4.1 for Windows and v1.2.0.7 of the c# Appium driver.

I have discovered that I can use the following adb commands to do ctrl+A via a batch file:

adb shell sendevent /dev/input/event4 4 4 458976
adb shell sendevent /dev/input/event4 1 29 1
adb shell sendevent /dev/input/event4 0 0 0
adb shell sendevent /dev/input/event4 4 4 458756
adb shell sendevent /dev/input/event4 1 30 1
adb shell sendevent /dev/input/event4 0 0 0
adb shell sendevent /dev/input/event4 4 4 458756
adb shell sendevent /dev/input/event4 1 30 0
adb shell sendevent /dev/input/event4 0 0 0
adb shell sendevent /dev/input/event4 4 4 458976
adb shell sendevent /dev/input/event4 1 29 0
adb shell sendevent /dev/input/event4 0 0 0

Any input greatly appreciated.
Thanks
Alan

bump

Thought I’d add a little bit more context.

My use case is that I’m using an Android app to access Windows apps and need to be able to send Windows Shortcuts such as CTRL+C, CTRL+V, CTRL+Z etc to the Windows apps. I have an external keyboard attached to my Android device, such as a Bluetooth keyboard with CTRL keys, or a standard PC keyboard to do this.

Ideally I would use an Appium API, but I am having difficulty getting the KeyEvent with Metastate info call to work. Please advise how I can get this to work, or if there is another way.

As an alternative, as I can get key combinations to work by sending sendevents via adb as described previously, it would be great if it were possible to send these adb commands via a batch file through Appium, or send the sendevents via and Appium API call. Is this currently possible?