From a1b11a226588580703cf02f3d8d94035b342a943 Mon Sep 17 00:00:00 2001 From: Emi Date: Sat, 5 Jul 2025 23:16:40 -0300 Subject: [PATCH] little changes on script --- script.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/script.py b/script.py index 9547613..d2c6728 100644 --- a/script.py +++ b/script.py @@ -1,6 +1,7 @@ import pyautogui as pgui import time from pynput import keyboard as kb +import sys quit = False @@ -25,14 +26,14 @@ browser_img = 'brave.png' browser_loc = pgui.locateCenterOnScreen(f'img/{browser_img}', confidence=0.8) -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) - - +if browser_loc: + pgui.moveTo(browser_loc, duration=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.") + sys.exit('closing script') pgui.hotkey('ctrl', 't')