展会信息港展会大全

Android: 用Instrumentation类发送鼠标或按键事件
来源:互联网   发布日期:2015-10-02 16:07:33   浏览:1296次  

导读:模拟鼠标MotionEvent.ACTION_DOWN:new Thread () {public void run () {try { Instrumentation inst=new Instrumentation(); inst.sendPointerSync(MotionEven......

模拟鼠标MotionEvent.ACTION_DOWN:

new Thread () {

public void run () {

try {

Instrumentation inst=new Instrumentation();

inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),

SystemClock.uptimeMillis(),

MotionEvent.ACTION_DOWN, 240, 400, 0));

inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),

SystemClock.uptimeMillis(),

MotionEvent.ACTION_UP, 240, 400, 0));

} catch(Exception e) {

Log.e("Exception when sendPointerSync", e.toString());

}

}

}.start();

赞助本站

人工智能实验室

相关热词: Instrumentation 按键

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港