Generation

fix invalid codeSun, 22 Jan 2023

import pyautogui, time, winsound, os screen_width, screen_height = pyautogui.size() scroll_amount = int(screen_height * 0.1) # scroll 10% of the screen height # Read config values from config.txt file current_dir = os.path.dirname(os.path.abspath(__file__)) config_file_path = os.path.join(current_dir, 'config.txt') with open(config_file_path, 'r') as config_file: config = {line.split(':')[0]:line.split(':')[1].strip() for line in config_file} # Assign config values to variables execution_interval = float(config['execution_interval']) per_button_set_interval = float(config['per_button_set_interval']) image_list = ["u1.png","u2.png","u3.png","u4.png","reload.png"] clicked_buttons = set() def click_button(button_location): pyautogui.click(button_location) time.sleep(execution_interval) clicked_buttons.add(button_location) while True: # Take a screenshot of the section where the buttons are located screenshot = pyautogui.screenshot() # Use image recognition to locate the buttons in the screenshot current_dir = os.path.dirname(os.path.abspath(__file__)) for i, image in enumerate(image_list): btn_location = pyautogui.locateOnScreen(os.path.join(current_dir, "buttons", image), screenshot) if btn_location and btn_location not in clicked_buttons: click_button(btn_location) else: # if any button not found, break the loop break # Scroll down pyautogui.scroll(-scroll_amount) # wait for the new chat to load time.sleep(per_button_set_interval) print("all buttons clicked!") winsound.Beep(440, 1000)

Want to kickstart your project?Use the new AI Studio to create your code