search
HomeDatabaseMysql TutorialM2真机模拟事件

M2真机模拟事件

Jun 07, 2016 pm 03:00 PM
eventcell phonesimulationTaobaoReal machineDesign and Developmentneed

需求:是想设计开发一款淘宝手机(android)的客户端的刷红包插件。 部分参考http://blog.csdn.net/chaihuasong/article/details/9159323 http://wenku.baidu.com/link?url=xHtaog9mpgVQE7oU02k1Lz3FoqKYqvpbRmSycNv63okGL6cI4UaFBw7HaN02ZWouaIc2pIBrdYxNEH

需求:是想设计开发一款淘宝手机(android)的客户端的刷红包插件。

部分参考http://blog.csdn.net/chaihuasong/article/details/9159323

http://wenku.baidu.com/link?url=xHtaog9mpgVQE7oU02k1Lz3FoqKYqvpbRmSycNv63okGL6cI4UaFBw7HaN02ZWouaIc2pIBrdYxNEHyNuVj0J1kY8efgcw2mSGlMfG4IKiO

http://my.oschina.net/zhangqingcai/blog/36272

解压D:\16教程之家\视频教程\01Android教程\android-documents下的sdk,设置好adb的path路径,并安装好手机驱动。

 

在控制台键入如图所示:

M2真机模拟事件

表示驱动安装成功。而非模拟器。

 

然后可以利用下图所示,查看本机的事件列表:

M2真机模拟事件


很明显的是event1为powerkey,也就是电源键。

 

adb的作用:

http://www.iteye.com/topic/260042

Android 调试桥(adb)是多种用途的工具,该工具可以帮助你你管理设备或模拟器 的状态。

可以通过下列几种方法加入adb:

在设备上运行shell命令

通过端口转发来管理模拟器或设备

从模拟器或设备上拷贝来或拷贝走文件

 

利用adb像手机发送消息,完成点击,移动,滑动等操作效果。

下面是控制手机电源键代码

@echo off
adb shell sendevent /dev/input/event1 1 $((0x74)) 1
adb shell sendevent /dev/input/event1 0 0 0
adb shell sendevent /dev/input/event1 1 $((0x74)) 0
adb shell sendevent /dev/input/event1 0 0 0
pause & exit

其中 event1代表手机电源事件,1表示触发操作,0x74表示code,1表示value(1代表按下,0表示弹出)

下面是点击事件:

@echo off
adb shell sendevent /dev/input/event0 3 $((0x39)) $((0x1a15))
adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x2))

adb shell sendevent /dev/input/event0 3 $((0x35)) $((0x1d7))
adb shell sendevent /dev/input/event0 3 $((0x36)) $((0x2c0))

adb shell sendevent /dev/input/event0 3 $((0x3a)) $((0x1b))

adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 3 $((0x39)) $((ffffffff))
adb shell sendevent /dev/input/event0 0 0 0
pause & exit

其中,利用了event0 3 $((0x3a))$((0x1b))表示点击,event0 3 $((0x35))$((0x1d7)),event0 3 $((0x36))$((0x2c0))表示x轴,y轴坐标。

 

下面表示移动事件:

@echo off
adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x4))

adb shell sendevent /dev/input/event0 3 $((0x35)) 250
adb shell sendevent /dev/input/event0 3 $((0x36)) 670

adb shell sendevent /dev/input/event0 3 $((0x3a)) $((0x1f))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x21))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x21))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x24))
adb shell sendevent /dev/input/event0 0 0 0


adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x26))
adb shell sendevent /dev/input/event0 0 0 0


adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x28))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x35)) $((0x41))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x3a)) $((0x00))
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x39)) $((ffffffff))
adb shell sendevent /dev/input/event0 0 0 0
pause & exit
或
@echo off
adb shell sendevent /dev/input/event0 3 $((0x39)) $((0x1a7e))
adb shell sendevent /dev/input/event0 3 $((0x30)) $((0x2))
adb shell sendevent /dev/input/event0 3 $((0x35)) $((0xc1))
adb shell sendevent /dev/input/event0 3 $((0x36)) $((0x2c1))

adb shell sendevent /dev/input/event0 1 330 1---按下
adb shell sendevent /dev/input/event0 0 0 0

adb shell sendevent /dev/input/event0 3 $((0x35)) $((0xc1))
adb shell sendevent /dev/input/event0 3 $((0x36)) $((0x201))

adb shell sendevent /dev/input/event0 3 $((0x35)) $((0x2d1))
adb shell sendevent /dev/input/event0 3 $((0x36)) $((0x201))

adb shell sendevent /dev/input/event0 1 330 0----弹出
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 3 $((0x39)) $((ffffffff))
adb shell sendevent /dev/input/event0 0 0 0
pause & exit

利用getevent,可以获取当前手机中的操作代码。

M2真机模拟事件

利用sendevent则可以通过adb发送事件。

M2真机模拟事件

监听到的真机上的事件代码:

M2真机模拟事件

M2真机模拟事件

问题汇总:

对于再刮一张的点击,能够很好的完成(注意如果利用touch,即330不够完美)。


M2真机模拟事件

对于滑动,可以看到,利用代码,可以绘制出一个直线,这是滑动屏幕的结果。

M2真机模拟事件

但在下面的红包的应用中,发现,滑动时,却不能很好的完成操作。其实在上面的滑动过程中,已经发现,对于滑动过程,利用代码,滑动非常缓慢,这也是下面图形不能刮开的一个原因。

M2真机模拟事件

由于刮的非常慢,所以会作出一个选择的操作,而不是一下滑动。而在有道笔记的应用中,view中没有提供选择,所以可以划出线条。

 

 

猜测关键:

1.     利用批处理,本身运行每个命令很慢(或有个默认时间)。

2.     Adb发送消息,有一个默认的时间间隔。

3.      

 



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.