Android: 用Instrumentation类发送鼠标或按键事件

模拟鼠标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(); 

你可能感兴趣的:(thread,android,exception,UP)