Beispiel #1
0
def main():
    '''Main function of the script'''
    parser = argparse.ArgumentParser()
    parser.add_argument('--all', '-a', action='store_true')
    parser.add_argument('--interactive', '-i', action='store_true')

    args = parser.parse_args()

    logger = CliLogger()
    screen = Screen()

    analytics = Analytics(logger)
    resources = Resources()
    analytics.ignore = ANALYTICS_IGNORE
    resources.load(analytics)

    if args.interactive:
        handle = wait_league_window(logger, (0, 0, 1024, 768))
        screen.d3d.capture(target_fps=10, region=find_rect(handle))
        while True:
            if keyboard.is_pressed('x'):
                cv2.destroyAllWindows()
                screen.d3d.stop()
                break
            img = screen.d3d.get_latest_frame()
            if img is None:
                continue
            try:
                img_bgr = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
                objs = tick(logger, analytics, resources, img)
                draw_objects(img_bgr,
                             objs,
                             wait=False,
                             title='League Vision - Interactive')
                logger.log('Press and hold x to exit bot.')
            except NoCharacterInMinimap:
                pass
            logger.log('-' * 50)
            time.sleep(1)
        return

    if args.all:
        files = glob.glob('screenshots/*.png')
    else:
        files = glob.glob('screenshots/*.png')[:1]

    for file in files:
        img_bgr = cv2.imread(file)
        img = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
        try:
            objs = tick(logger, analytics, resources, img)
            logger.log('Press x to exit.')
        except NoCharacterInMinimap:
            pass
        logger.log('-' * 50)
        if draw_objects(img_bgr, objs, title=f'League Vision - {file}') == 120:
            break
Beispiel #2
0
def main():
    '''Main function of the script'''
    logger = CliLogger()
    analytics = Analytics(logger)
    analytics.ignore = [
        'screenshot', 'get_minimap_coor', 'get_minimap_areas', 'get_objects'
    ]
    screen = Screen()
    hwnd = wait_league_window(logger, (0, 0, 1024, 768))
    time.sleep(1)

    logger.log('Press and hold x to exit bot.')
    while True:
        if keyboard.is_pressed('x'):
            break
        img = screen.screenshot(find_rect(hwnd))
        time.sleep(1)
Beispiel #3
0
def main():
    '''Main function of the script'''
    paused = False

    logger = CliLogger()
    screen = Screen()
    resources = Resources()
    analytics = Analytics(logger)
    cooldown = Cooldown(COOLDOWNS)
    analytics.ignore = ANALYTICS_IGNORE
    resources.load(analytics)
    utility = Utility(logger, screen, resources, analytics, cooldown)
    logic = Logic(utility)
    try:
        handle = wait_league_window(logger, (0, 0, 1024, 768))
    except CantForgroundWindowError:
        pass
    logger.log('Press and hold x to exit bot.')
    screen.d3d.capture(target_fps=10, region=find_rect(handle))
    while True:
        try:
            if keyboard.is_pressed('x'):
                raise BotExitException
            if keyboard.is_pressed('ctrl+u'):
                paused = False
            if paused:
                time.sleep(0.1)
                continue
            if keyboard.is_pressed('ctrl+p'):
                paused = True
                logger.log(
                    'Bot paused. Press ctrl+u to unpause. Press x to exit.')
                continue
            logic.tick()
            time.sleep(random.randint(*TICK_INTERVAL) / 1000)
        except BotContinueException as exp:
            time.sleep(random.randint(*exp.tick_interval) / 1000)
        except NoCharacterInMinimap:
            time.sleep(1)
        except BotExitException:
            screen.d3d.stop()
            break
        except Exception:  # pylint:disable=broad-except
            traceback.print_exc()
            screen.d3d.stop()
            break
Beispiel #4
0
def main():
    '''Main function of the script'''
    logger = CliLogger()
    screen = Screen()

    handle = wait_league_window(logger, (0, 0, 1024, 768))
    rect = find_rect(handle)

    logger.log('Window found.')
    logger.log('ctrl+s to save')
    logger.log('ctrl+w to exit')

    def screenshot():
        nonlocal logger, screen, rect
        img = screen.screenshot(rect)
        export_data(logger, img)

    keyboard.add_hotkey('ctrl+s', screenshot)
    keyboard.wait('ctrl+w')
Beispiel #5
0
def main():
    '''Main function of the script'''
    root = tkinter.Tk()
    root.title('Training Data Generator')
    canvas = tkinter.Canvas(root, width=300, height=300)
    canvas.pack()
    canvas_img = canvas.create_image(20, 20, anchor="nw")
    root.mainloop(n=1)

    parser = argparse.ArgumentParser()
    parser.add_argument('--all', '-a', action='store_true')
    parser.add_argument('--interactive', '-i', action='store_true')

    args = parser.parse_args()

    logger = CliLogger()
    screen = Screen()
    analytics = Analytics(logger)

    def tick_gui(img):
        tick(lambda: askstring('Enter label. Type exit to stop.', root, parent=root),
             lambda i: canvas.itemconfig(canvas_img, image=i), img)

    if args.interactive:
        hwnd = wait_league_window(logger, (0, 0, 1024, 768))
        img = screen.screenshot(analytics, find_rect(hwnd))
        img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
        tick_gui(img)
        return
    if args.all:
        files = glob.glob('screenshots/*.png')
    else:
        files = [glob.glob('screenshots/*.png')[0]]
    for file in files:
        img = cv2.imread(file)
        tick_gui(img)