Exemple #1
0
def open_website(link):
    wpm = 250
    keyboard.send("f6")
    time.sleep(0.1)
    typist = Typist(wpm)
    typist.insert_characters(link)
    sleep_time = (len(link) / (wpm * 5)) * 60 + 1.5
    time.sleep(sleep_time)
    keyboard.send("enter")
Exemple #2
0
def race_bot():
    # wait for the user to open the typeracer website
    time.sleep(3)

    successful_types = 0
    unsuccessful_types = 0

    while True:
        open_website("https://typeracer.com/")
        time.sleep(5)  # wait for it to load

        enter_race()

        if not search_for_yellow_light():
            continue
        # premature quote grab
        premature_text, _ = get_typing_content()
        typist = Typist(config.wpm, config.accuracy, config.error_deviation)
        time.sleep(3.4)
        typist.insert_characters(premature_text[0:25])
        time.sleep(0.5)
        # take a screenshot and save it
        text, bounding_box = get_typing_content()
        text_continuation = find_text_continuation(premature_text, text, 25)
        typist.insert_characters(text_continuation)
        text = premature_text[0:25] + text_continuation
        textbox_location = (config.mouse_width_typebox, bounding_box[3] +
                            config.mouse_offset_of_change_display_typebox)
        while not typist.is_finished():
            typo_flag = wait_for_text_to_be_written(3, textbox_location)
            if typist.is_finished():
                typo_flag = False
                break
            if typo_flag:
                break
        typist.stop_typing()

        if typo_flag:
            append = "typo"
            unsuccessful_types += 1
        else:
            append = "correct"
            successful_types += 1

        with open("quotes_log_" + append + ".txt", 'a') as f:
            f.write(text + "\n")

        time.sleep(0.3)
        print("Sucessful: {} | Unsuccessful: {}".format(
            successful_types, unsuccessful_types))