See GitHub has a lot of wechat to jump to the aid, but all need to rely on PC, yesterday thinking can only use android to write a local assistant, first look at the effect:
Implementation approach
- Transparent floating window
- Finger slide through onTouch to get the spacing of the slide
- Scale the time required to press long
- Simulate a long press using shell commands (requires ROOT permission)
The main code
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
caseMotionevent.action_down: // Press log.d (TAG,"Starting position:" + event.getRawX() + "" + event.getRawY());
mStartX = event.getRawX();
mStartY = event.getRawY();
break;
caseMotionevent.action_up: // Release log.d (TAG,"End position:" + event.getRawX() + "" + event.getRawY());
float endX = event.getRawX();
floatendY = event.getRawY(); // The side of the triangle is 1floatlength1 = Math.abs(endX - mStartX); // The sides of the triangle are 2floatlength2 = Math.abs(endY - mStartY); Int distance = (int) length.sqrt (length.pow (length1, 2) + length.pow (length2, 2)); Log.d(TAG,"Distance:"+ distance); Int temp = (distance * 1.44); // It takes a few tries to find the best timeexec("input swipe 600 1800 600 1800 " + (temp) + "\n");
break;
}
return true;
}Copy the code
project
- Project source code: github.com/lvkaixuan/J…
- Project Demo: fir.im/ wechatJump (if the download is full, please scan the qr code below)
- If the project is helpful to you, I hope you can move your lovely little hand star
- Scan code to download Demo to try
Thank you
- Thanks to GitHub’s floating Window frame: github.com/yhaolpz/Flo…