Example #1
0
    def open(self, type, times):
        red_y = 700
        red_x_20 = 200
        red_x_100 = 550
        red_x_500 = 900
        album_x = 500
        album_y = 1500

        if type == '20':
            x = red_x_20
            y = red_y
        elif type == '100':
            x = red_x_100
            y = red_y
        elif type == '500':
            x = red_x_500
            y = red_y
        elif type == 'album':
            x = album_x
            y = album_y
        else:
            return

        for i in range(times):
            Adb.tap_random(x - 100, y - 100, x + 100, y + 100)
            time.sleep(0.2)
            if i % 10 == 0:
                Adb.screen_shot(self.__png_name, self.__screenshot_path)
        for i in range(10):
            Adb.tap_random(red_x_500 - 100, red_y - 100, red_x_500 + 100,
                           red_y + 100)
            time.sleep(0.2)
        Adb.screen_shot(self.__png_name, self.__screenshot_path)
Example #2
0
    def __ad_close_template(self, img, close_pos, close_template_name):
        threshold = 0.85
        close_template = cv2.imread(close_template_name, 0)
        close = img[close_pos['y0']:close_pos['y1'],
                    close_pos['x0']:close_pos['x1']]
        match_rate = cv2.matchTemplate(close, close_template,
                                       cv2.TM_CCOEFF_NORMED)
        # print(close_template_name)
        # print(match_rate)
        if (match_rate > threshold).any():
            Adb.tap_random(close_pos['x0'] + 20, close_pos['y0'] + 20,
                           close_pos['x1'] - 20, close_pos['y1'] - 20)
            time.sleep(2)
            Adb.tap_random(270, 585, 270 * 3, 585 * 3)
            return 1

        return 0
Example #3
0
    def __ad_start(self):
        png_file = Adb.screen_shot(self.__png_name, self.__screenshot_path)
        img = cv2.imread(png_file, 0)
        threshold = 0.975
        ad_pos = {'x0': 945, 'y0': 255, 'x1': 1045, 'y1': 345}
        ad_template = cv2.imread(self.__ad_template_path + '/ad_template.png',
                                 0)

        ad = img[ad_pos['y0']:ad_pos['y1'], ad_pos['x0']:ad_pos['x1']]
        match_rate = cv2.matchTemplate(ad, ad_template, cv2.TM_CCOEFF_NORMED)
        # print('start:')
        # print(match_rate)
        if (match_rate > threshold).any():
            Adb.tap_random(ad_pos['x0'] + 20, ad_pos['y0'] + 20,
                           ad_pos['x1'] - 20, ad_pos['y1'] - 20)
            time.sleep(1)
            Adb.tap_random(590, 1450, 960, 1520)
Example #4
0
 def __auto_tap(self):
     for k in self.__pos:
         Adb.tap_random(self.__pos[k][0] - 25, self.__pos[k][1] - 25,
                        self.__pos[k][0] + 25, self.__pos[k][1] + 25)
         time.sleep(0.25)
Example #5
0
 def __force_close(self):
     Adb.tap(1000, 160)
     time.sleep(2)
     Adb.tap_random(270, 585, 270 * 3, 585 * 3)