使用代码刷QQ的跨年红包

使用的库从这里找:

https://github.com/GameTerminator/dont-touch-white

关键代码就是一个while循环加上drag。

import com.android.chimpchat.adb.AdbBackend;
import com.android.chimpchat.core.IChimpDevice;

import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        AdbBackend adbBack = new AdbBackend();
        IChimpDevice mChimpDevice = adbBack.waitForConnection();
        System.out.println("连接");
        long time = System.currentTimeMillis();
        while (System.currentTimeMillis() - time < 60000) {
            mChimpDevice.drag(300, 200, 400, 600, 10, 50);
            Thread.sleep(10);
        }
    }
}

再修改了一下,1开始,2退出,其他跳过。


import com.android.chimpchat.adb.AdbBackend;
import com.android.chimpchat.core.IChimpDevice;

import java.io.IOException;
import java.util.Scanner;

public class Main {
       

    private static int action = 0;

    public static void main(String[] args) throws IOException, InterruptedException {
        AdbBackend adbBack = new AdbBackend();
        IChimpDevice mChimpDevice = adbBack.waitForConnection();
        System.out.println("连接");

        new Thread(new Runnable() {
            @Override
            public void run() {
                Scanner scanner = new Scanner(System.in);
                while (true) {
                    action = scanner.nextInt();
                    if (action == 2) {
                        return;
                    }
                }
            }
        }).start();

        long time = System.currentTimeMillis();
        int times = 0;
        while (System.currentTimeMillis() - time < 60000) {
            if (action == 1) {
                mChimpDevice.drag(300, 200, 400, 600, 10, 50);
                times++;
                System.out.println(times + "次");
            }
            if (action == 2) {
                return;
            }
            Thread.sleep(10);
        }

    }
}

你可能感兴趣的:(移动开发,java)