From 0519e67cb05fe47be9fee48d11b3b018494020dd Mon Sep 17 00:00:00 2001 From: Emi Date: Sat, 5 Jul 2025 23:10:41 -0300 Subject: [PATCH] refactor script.py --- script.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/script.py b/script.py index e1be552..f6bcf0c 100644 --- a/script.py +++ b/script.py @@ -1,24 +1,22 @@ import pyautogui as pgui import time import keyboard as kb +import sys -quit = False - # Enter the name of your browser, based on the name of its icon image. -browser = 'brave' +browser_img = 'brave.png' -browser_loc = pgui.locateCenterOnScreen(f'img/{browser}.png', confidence=0.8) +browser_loc = pgui.locateCenterOnScreen(f'img/{browser_img}', confidence=0.8) if browser_loc: pgui.moveTo(browser_loc, duration=0.2) - time.sleep(0.2) pgui.click() # Change the time depending on how long it takes to open your browser time.sleep(2) else: print("Browser icon not found.") - exit() + sys.exit('closing script') pgui.hotkey('ctrl', 't') @@ -29,12 +27,11 @@ pgui.press("enter") # change depending on how long it takes to load yt time.sleep(5) -while not quit: +while True: if kb.is_pressed('q'): print(':(') - quit = True - continue + break opt_loc = pgui.locateCenterOnScreen('img/options.png', confidence=0.8)