예제 #1
0
def check_circle(circle_path, threshold):
    print(print_name(circle_path))
    i = 0
    while i < 60:
        i += 1
        screenshot.window_capture(const.Const.screen_path)
        try:
            mainScreen = ac.imread(const.Const.screen_path)
            circleScreen = ac.imread(circle_path)
            template = ac.find_all_template(mainScreen,
                                            circleScreen,
                                            rgb=True,
                                            threshold=threshold,
                                            bgremove=True)
            if template is None or len(template) <= 0:
                continue
            else:
                sort_template = sorted(template, key=lambda x: x["result"])
                for t in sort_template:
                    # print(t['rectangle'][1])
                    win32api.SetCursorPos(
                        (int(t['result'][0]), int(t['result'][1])))
                    # win32api.SetCursorPos((int(t['rectangle'][1][0]), int(t['rectangle'][1][1])))
                    time.sleep(0.5)
                time.sleep(1)
                break
        except:
            pass
        time.sleep(config.conf.screenshot_main_time)
    else:
        print(print_name(circle_path) + ",没有识别出来")
예제 #2
0
def grab_screen():
    if config.conf.cron_start != "yes":
        return
    now = datetime.datetime.now()
    d_i_r = "{0}\\{1}".format(config.conf.cron_screenshot_file_path,
                              now.strftime('%Y-%m-%d'))
    if not os.path.exists(d_i_r):
        os.mkdir(d_i_r)

    jpg__format = "{0}\\{1}.jpg".format(d_i_r, now.strftime('%H-%M-%S'))
    # print(jpg__format)
    screenshot.window_capture(jpg__format)
    t = Timer(config.conf.cron_screenshot_time, grab_screen)
    t.start()
예제 #3
0
def handler_web_close():
    while 1:
        try:
            time.sleep(2)
            screenshot.window_capture(const.Const.screen_path)
            screen = ac.imread(const.Const.screen_path)
            close_screen = ac.imread(const.CLOSE_PATH)
            template = ac.find_template(screen, close_screen, threshold=0.9)
            if template is None:
                continue
            print("页面无投注退出弹框...刷新网页")
            sys_logger.warning("web close...f5")
            win32api.keybd_event(116, 0, 0, 0)  # F5
            win32api.keybd_event(116, 0, win32con.KEYEVENTF_KEYUP,
                                 0)  # Realize the F5 button
        except Exception as e:
            sys_logger.error(e)
예제 #4
0
def pick_origin(is_check):
    i = -300
    if is_check:
        print("第一个格子的坐标(用于定位其他的格子)")
        i = 0

    while i < 60:
        i += 1
        screenshot.window_capture(const.Const.screen_path)
        mainScreen = ac.imread(const.Const.screen_path)
        originScreen = ac.imread(const.ORIGIN_PATH)
        time.sleep(config.conf.screenshot_main_time)
        template = ac.find_template(mainScreen, originScreen, threshold=0.9)
        if template is None:
            continue
        # print(template['rectangle'][1])
        if is_check:
            win32api.SetCursorPos(template['rectangle'][1])
        return template['rectangle'][1]
    return None
예제 #5
0
def handler_new_game():
    while 1:
        try:
            time.sleep(3)
            screenshot.window_capture(const.Const.screen_path)
            screen = ac.imread(const.Const.screen_path)
            game_start_screen = ac.imread(const.GAME_START_PATH)
            template = ac.find_template(screen,
                                        game_start_screen,
                                        threshold=0.9)
            if template is None:
                continue
            local_pos = pos_json.get_local_pos()
            if local_pos['列数'] < 24:
                continue
            mv(config.conf.data_save_dir + '//ing.json', "结果")
            mv(config.conf.data_save_dir + '//array_ing.json', "矩阵")
            print("新开一局!!!")
            sys_logger.warning("新开一局")
        except Exception as e:
            sys_logger.error(e)
예제 #6
0
def fill_pos_array():
    while 1:
        screenshot.window_capture(const.Const.screen_path)
        originScreen = ac.imread(const.ORIGIN_PATH)
        circleScreen = ac.imread(const.RED_CIRCLE_PATH)
        circleScreen2 = ac.imread(const.BLUE_CIRCLE_PATH)
        circleScreen3 = ac.imread(const.HE_RED_CIRCLE_PATH)
        circleScreen4 = ac.imread(const.HE_BLUE_CIRCLE_PATH)
        pos_list.clear()
        try:
            screen = ac.imread(const.Const.screen_path)

            originTemplate = ac.find_template(screen,
                                              originScreen,
                                              threshold=0.9,
                                              rgb=True,
                                              bgremove=True)
            if originTemplate is None:
                time.sleep(config.conf.screenshot_main_time)
                continue
            origin = originTemplate['rectangle'][1]
            print(origin)

            template = ac.find_all_template(
                screen,
                circleScreen,
                rgb=True,
                threshold=config.conf.red_circle_threshold,
                bgremove=True)
            if template is not None and len(template) > 0:
                for t in template:
                    pos_list.append((t['rectangle'][0], const.RED_VALUE))

            template2 = ac.find_all_template(
                screen,
                circleScreen2,
                rgb=True,
                threshold=config.conf.blue_circle_threshold,
                bgremove=True)
            if template2 is not None and len(template2) > 0:
                for t in template2:
                    pos_list.append((t['rectangle'][0], const.BLUE_VALUE))

            template3 = ac.find_all_template(
                screen,
                circleScreen3,
                rgb=True,
                threshold=config.conf.he_red_circle_threshold,
                bgremove=True)
            if template3 is not None and len(template3) > 0:
                for t in template3:
                    pos_list.append((t['rectangle'][0], const.HE_RED_V))

            template4 = ac.find_all_template(
                screen,
                circleScreen4,
                rgb=True,
                threshold=config.conf.he_blue_circle_threshold,
                bgremove=True)
            if template4 is not None and len(template4) > 0:
                for t in template4:
                    pos_list.append((t['rectangle'][0], const.HE_BLUE_V))

            new_pos_list = sorted(pos_list, key=lambda x: x[0])
            if len(new_pos_list) > 0:
                handle_circle_pos(new_pos_list, origin)

        except Exception as e:
            sys_logger.error(e)

        time.sleep(config.conf.screenshot_main_time)