ADB——模拟手机按键输入
基本命令
adb 模拟按键输入的命令主要通过 input 进行
Usage: input [<source>] <command> [<arg>...]
The sources are:
mouse
keyboard
joystick
touchnavigation
touchpad
trackball
stylus
dpad
gesture
touchscreen
gamepad The commands and default sources are:
text <string> (Default: touchscreen)
keyevent [--longpress] <key code number or name> ... (Default: keyboard)
tap <x> <y> (Default: touchscreen)
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll <dx> <dy> (Default: trackball)
参数解释
常用命令
物理键:
adb shell input keyevent 26 # 电源键
adb shell input keyevent 82 # 菜单键
adb shell input keyevent 3 # HOME 键
adb shell input keyevent 4 # 返回键
adb shell input keyevent 24 # 音量+
adb shell input keyevent 25 # 音量-
adb shell input keyevent 164 # 静音
媒体控制
adb shell input keyevent 85 # 播放/暂停
adb shell input keyevent 86 # 停止播放
adb shell input keyevent 87 # 播放下一首
adb shell input keyevent 88 # 播放上一首
adb shell input keyevent 126 # 恢复播放
adb shell input keyevent 127 # 暂停播放
点亮/熄灭屏幕
可以通过上 模拟电源键 来切换点亮和熄灭屏幕,但如果明确地想要点亮或者熄灭屏幕,那可以使用如下方法。
adb shell input keyevent 224 # 点亮屏幕
adb shell input keyevent 223 # 熄灭屏幕
触击屏幕
adb shell input tap <X> <Y> # x,y为坐标位置
滑动屏幕
划动屏幕用到了 swipe 命令,它有四个参数,分别是起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标。
如果锁屏没有密码,是通过滑动手势解锁,那么可以通过 input swipe 来解锁。
# 四个参数:起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标。
adb shell input swipe 300 1000 300 500 # 向上滑动
adb shell input swipe 300 100 300 1000 # 向下滑动
adb shell input swipe 1000 500 200 500 # 向左滑动
adb shell input swipe 200 500 1000 500 # 向右滑动
输入文本
在焦点处于某文本框时,可以通过 input 命令来输入文本。
adb shell input text hello # 输入hello
keyevent 命令大全
官方文档地址:https://developer.android.com/reference/android/view/KeyEvent
中文keycode大全:adb——keyevent命令大全
ADB——模拟手机按键输入的更多相关文章
- Helium文档5-WebUI自动化-press模拟键盘按键输入技巧
前言 press方法是用来模拟键盘按键输入,可以组合使用,来模拟键盘输入,解决一些难定位的元素 入参介绍 以下是press源码中的函数介绍 def press(key): :入参 :param ke ...
- Android adb 模拟滑动 按键 点击事件
模拟事件全部是通过input命令来实现的,首先看一下input命令的使用: usage: input ... input text <string> input keyeven ...
- Android应用程序模拟手机按键
记得以前在做一个C++项目时,需要在某一步操作之后人为用代码模拟敲键盘上的回车键(Enter)效果. 出于好奇,这几天研究了一下Android中手机(或平板)上各种按键的键值.模拟方法及最终效果. 1 ...
- 【python-appium】模拟手机按键搜索异常
执行代码的过程中运行self.driver.press_keycode(84)设备没反映,则需要关闭#desired_caps["unicodeKeyboard"] = " ...
- Python脚本控制的WebDriver 常用操作 <十二> send_keys模拟按键输入
下面将使用WebDriver中的send_keys来模拟键盘按键输入 测试用例场景 send_keys方法可以模拟一些组合键操作: ctrl+a ctrl+c ctrl+v 等. 另外有时候我们需要在 ...
- adb命令模拟按键输入keycode
adb命令模拟按键输入keycode 2017年05月18日 14:57:32 阅读数:1883 例子: //这条命令相当于按了设备的Backkey键 adb shell input keyevent ...
- adb shell命令模拟按键/输入input使用keycode 列表详解
在adb shell里有一个非常使用的命令,模拟按键输入,这里首先不要理解为是键盘的模拟按键,下面命令的使用和键值做一个详解. input命令格式 adb shell input keyevent & ...
- linux下如何模拟按键输入和模拟鼠标【转】
转自:http://www.cnblogs.com/leaven/archive/2010/11/30/1891947.html 查看/dev/input/eventX是什么类型的事件, cat /p ...
- Python 脚本利用adb 进行手机控制
相关参考:https://www.cnblogs.com/bravesnail/articles/5850335.html 一. adb 相关命令: 1. 关闭adb服务:adb kill-serv ...
随机推荐
- EurekaClient项目启动报错Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'e
Disconnected from the target VM, address: '127.0.0.1:51233', transport: 'socket' Eureka Client的使用 使用 ...
- python中关于变量名失效的案例
案例一:传参动态导入模块. selectModule = input("please input your module name") app_name = input(" ...
- 金蝶K/3 报销相关SQL语句
金蝶K/3 报销相关SQL语句 use AIS20180607113701 select fopenid,* from dbo.t_XunTong_User where Fname ='' go us ...
- OK Titlefasdf asd
Do a lot of material ! asdfa sdgadfasdg Android is ok, IOS is also ok.
- matplotlib坐标轴设置续-【老鱼学matplotlib】
本次会讲解如何修改坐标轴的位置. 要修改轴,就要先得到当前轴:plt.gca(),这个函数名挺怪的,其实是如下英文字母的首字母:get current axis,也就是得到当前的坐标轴. import ...
- 记一次Mysql魔鬼实训
1.查看某个Mysql数据库当前使用的字符集 show create database [库名称] 2.查看当前书库版本信息 #mysql -V MariaDB [(none)]> use my ...
- Noj - 在线强化训练3
状态 题号 竞赛题号 标题 1091 A 求解逆波兰表达式(Calculate the reverse Polish notation) 1017 B 数列 1323 C 穷举n位二进制数 ...
- Failed global initialization:FileNotOpen: Failed to open "C:\MongoDB\data\log\mongo.log" 安装MongoDB时卡死
在安装MongoDB的时候,下载了3.6版本,安装过程中发现到一半就卡死了,后面换了一个较低版本的才安装成功 这里是所有MongoDB版本的下载地址: https://www.mongodb.org/ ...
- js小笔记
1.let ,const,var 区别 let:块级作用域,if,for,用完就不存在了. const:用来定义常量. var: 声明的变量在它所声明的整个函数都是可见的. 2.==和===的区别 1 ...
- angular.equals()
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...