Android: 用Instrumentation类发送鼠标或按键事件
16lz
2022-06-18
模拟鼠标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();
更多相关文章
- adb连接不上模拟器的问题
- eclipse 新建 android 项目时,问题汇总
- android 模拟按键单值/多值输入
- android ------ Emulator: error: x86 emulation currently requ
- android 模拟抢红包 原理
- Android--学习笔记--02--AndroidStudio的设置
- android 127.0.0.1/localhost connection refused 问题的
- 植物大战僵尸2 Android破解版,免费买道具
- Android(安卓)使用模拟位置(支持Android(安卓)6.0)