@Override public void sendPointerSync(MotionEvent event) { base.sendPointerSync(event); }
MotionEvent event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_DOWN, fromX, fromY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} for (int i = 0; i < stepCount; ++i) { event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_MOVE, x, y, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP,toX, toY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {}
Thread thread = new Thread(){ @Override public void run(){ Instrumentation m_Instrumentation = new Instrumentation(); m_Instrumentation.sendPointerSync(MotionEvent.obtain( SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN,posx, posy, 0)); m_Instrumentation.sendPointerSync(MotionEvent.obtain( SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP,width*4/5,height, 0)); } };
public static void click(Point location) { final long time = SystemClock.uptimeMillis(); final MotionEvent actionDownEvent = MotionEvent.obtain( time, time, MotionEvent.ACTION_DOWN, location.x, location.y, 0); final MotionEvent actionUpEvent = MotionEvent.obtain( time + 100, time + 100, MotionEvent.ACTION_UP, location.x, location.y, 0); final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); instrumentation.sendPointerSync(actionDownEvent); instrumentation.sendPointerSync(actionUpEvent); instrumentation.waitForIdleSync(); } }
MotionEvent.ACTION_UP, x, y, 0); try{ inst.sendPointerSync(event); inst.sendPointerSync(event2); successfull = true; }catch(SecurityException e){
pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event);
0, 0, // deviceId, edgeFlags InputDevice.SOURCE_TOUCHSCREEN, 0); // source, flags _instrument.sendPointerSync(event); 2, pointerProperties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); 2, pointerProperties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event); 1, pointerProperties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); _instrument.sendPointerSync(event);
1, // y precision 0, 0, 0, 0); // deviceId, edgeFlags, source, flags _instrument.sendPointerSync(event); + (pp2.id << MotionEvent.ACTION_POINTER_INDEX_SHIFT), 2, pointerProperties, pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0); _instrument.sendPointerSync(event); MotionEvent.ACTION_MOVE, 2, pointerProperties, pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0); _instrument.sendPointerSync(event);
0); try { inst.sendPointerSync(event); 0); try { inst.sendPointerSync(event);
1, // y precision 0, 0, 0, 0 ); // deviceId, edgeFlags, source, flags _instrument.sendPointerSync(event); 1, 0, 0, 0, 0 ); _instrument.sendPointerSync(event); 1, 0, 0, 0, 0 ); _instrument.sendPointerSync(event);
inst.sendPointerSync(event); successfull = true; sleeper.sleep(MINI_WAIT); inst.sendPointerSync(event); if(time > 0) sleeper.sleep(time); inst.sendPointerSync(event); sleeper.sleep();
Instrumentation m_Instrumentation = new Instrumentation(); m_Instrumentation.sendPointerSync(motionEvent);
pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0 ); inst.sendPointerSync(event); properties, pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0); inst.sendPointerSync(event); pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0); inst.sendPointerSync(event); MotionEvent.ACTION_POINTER_2_UP, 2, properties, pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0); inst.sendPointerSync(event); MotionEvent.ACTION_UP, 1, properties, pointerCoords, 0, 0, 1, 1, 0, 0, 0, 0 ); inst.sendPointerSync(event);
@Override public void sendPointerSync(MotionEvent event) { base.sendPointerSync(event); }
@Override public void sendPointerSync(MotionEvent event) { base.sendPointerSync(event); }
import android.app.Instrumentation; public class MainActivity extends Activity { Instrumentation m_Instrumentation; public void onCreate(Bundle savedInstanceState) { m_Instrumentation = new Instrumentation(); int x=0; //your x coord in screen. int y=0; // your y coord in screen. m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),MotionEvent.ACTION_DOWN,x, y,0)); m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),MotionEvent.ACTION_UP,x, y,0)); } }
@Override @CallSuper public void sendPointerSync(MotionEvent event) { if (DEBUG) { Logger.d(TAG,"sendPointerSync"); } mInstrumentation.sendPointerSync(event); }
int test1[] = new int[2]; button2.getLocationInWindow(test1); //--->getting coordinates of second button final Instrumentation m_Instrumentation = new Instrumentation(); //firing event new Thread(new Runnable() { @Override public void run() { m_Instrumentation.sendPointerSync(MotionEvent.obtain( android.os.SystemClock.uptimeMillis(), android.os.SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN,test1[0]+10, test1[1]+10, 0)); } }).start();
private void CREATE_EVENT() { long action_time = SystemClock.uptimeMillis(); //MotionEvent.obtain(long downTime, long eventTime, int action, float x, float y, int metaState); MotionEvent motion_event = MotionEvent.obtain(action_time, action_time, MotionEvent.ACTION_DOWN, 250, 150, 0); new INJECT_EVENTS().execute(motion_event); } public class INJECT_EVENTS extends AsyncTask<MotionEvent, MotionEvent, MotionEvent> { @Override protected MotionEvent doInBackground(MotionEvent ... event) { Instrumentation inject_event = new Instrumentation(); event[0].recycle(); inject_event.sendPointerSync(event[0]); Log.i("TEST", event[0].toString() + " __________________________EVENT CREATED!"); return null; } }
@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_MOTIONEVENT: Bundle bundle = msg.getData(); float rx = bundle.getFloat("x"); float ry = bundle.getFloat("y"); mInst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), msg.arg1, rx, ry, 0)); break; } } };