Example #1
0
    def active(self, img):

        if time.time() - self.last_run < self.threshold:

            # logger.info('task ran recently, so skipping {}'.format(self.__str__()))
            return False

        if not self._active(img):
            return False

        img = crop_array(img, self.relevant_screen[0], self.relevant_screen[1])
        if len(self.negatives) > 0:
            for template in self.negatives:
                if len(match_template(img, template)[0]) > 0:
                    return False

        if len(self.positives) > 0:
            for template in self.positives:
                if len(match_template(img, template)[0]) == 0:
                    return False

        if len(self.pos_w_count) > 0:
            for (template, count) in self.pos_w_count:
                if len(match_template(img, template)[0]) < count:
                    return False

        return True
Example #2
0
    def _active(self, img):

        if self.template is None:
            return True

        img = crop_array(img, self.relevant_screen[0], self.relevant_screen[1])
        return len(utils.match_template(img, self.template)[0]) > 0
Example #3
0
    def _run(self, img):
        time.sleep(.2)
        locs = utils.match_template(img, self.template)
        utils.click(locs[1][0] + 3, locs[0][0] + 3)
        time.sleep(1)

        pw = 'q1w2e3r4'
        pyautogui.typewrite(pw)
Example #4
0
    def _run(self, img):
        time.sleep(.2)
        locs = utils.match_template(img, self.template)
        utils.click(locs[1][0] + 3, locs[0][0] + 3)
        time.sleep(1)

        time.sleep(1)

        key_press('home')
Example #5
0
    def _active(self, img):
        # print self.template_path
        #
        # if self.template_path == 'templates/bandori/repeatable_buttons/ok_pink_button.bmp':
        #     nani = cv2.matchTemplate(img, self.template, cv2.TM_CCOEFF_NORMED)
        #
        #     nani_max = np.max(nani)
        #     import IPython
        #     IPython.embed()

        return len(utils.match_template(img, self.template)[0]) > 0
Example #6
0
    def _run(self, img):
        logger.debug(self.template_path + ' activated')
        time.sleep(.2)
        locs = utils.match_template(img, self.template)

        pyautogui.moveTo(locs[1][0] + 3, locs[0][0] + 3)
        pyautogui.dragTo(locs[1][0] + 500, locs[0][0], 2)

        time.sleep(1)

        utils.key_press('home')

        time.sleep(1)
Example #7
0
    def _run(self, img):
        logger.info(' activated {}'.format(self.times_execute))

        if self.coords == (0, 0):
            locs = utils.match_template(img, self.template)
            pyautogui.moveTo(locs[1][0] + np.random.randint(1, 3), locs[0][0] + np.random.randint(1, 3), )
            utils.click(locs[1][0] + np.random.randint(1, 3), locs[0][0] + np.random.randint(1, 3),
                        button=self.button)
        elif self.coords == (-1, -1):
            # print('nani the f**k')
            pyautogui.click(button=self.button)
        else:
            pyautogui.click(self.coords[0] + np.random.randint(-10, 10),
                            self.coords[1] + np.random.randint(-10, 10),
                            button=self.button)
        # pyautogui.moveTo(69, 69)
        return True
Example #8
0
def crop_image(base_image, top_left_template, x_range = 600, y_range = 600):
    locs = match_template(base_image, top_left_template)

    x, y = locs[1][0] + 3, locs[0][0] + 3

    return base_image[x:x+x_range, y:y+y_range]
Example #9
0
 def _active(self, img):
     # print(len(utils.match_template(img, self.main_template)[0]))
     if len(utils.match_template(img, self.main_template)[0]) < 8 * 2:
         return False
     return super()._active(img)