模拟二维​​的KeyEvent与亚行的shell ALT,SHIFT等shell、KeyEvent、SHIFT、ALT

2023-09-06 11:18:19 作者:是你忘了我◇

使用亚行外壳输入的KeyEvent 某些关键事件可以被模拟。也有像修饰键 SHIFT_LEFT ALT_RIGHT 等。

With adb shell input keyevent certain key events can be simulated. There are also modifier keys like SHIFT_LEFT, ALT_RIGHT etc.

我想模拟两个键,例如Shift + A,但

I would like to simulate two keys, for instance SHIFT + A, but

 adb shell input keyevent SHIFT_LEFT; keyevent A

结果只在一个简单的 A 在屏幕上。

推荐答案

如果需要Shift + A键,那么你将不得不做以下顺序

if Shift + A is needed then you will have to do following sequence

Press shift
Press A
Release A
Release shift

这可以通过使用来完成

命令格式为:的SendEvent设备类型code值

command format: sendevent device type code value

[command]     [device]             [type]    [code]   [value]
sendevent    /dev/input/event0    1          229      1

的/ dev /输入/ EVENT0是将其​​发送到设备

/dev/input/event0 is the device to send it to

【类型】1是未知,我(也许code对设备的物理按键)

[type] 1 is unknow for me ( maybe code for physical button on device )

[code] 229仿真器的菜单按钮

[code] 229 is the MENU button of the emulator

[值] 1的keydown或preSS下降(为KEYUP或最多使用0)

[value] 1 is keydown or press down ( for keyup or up use 0 )

我写一个批处理文件发送事件到设备象下面这样:

i wrote a batch file for sending the event to the device like below:

adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 1
adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 0

参考