mirror of
https://github.com/FranP-code/classify_saved_videos_yt.git
synced 2025-10-13 00:32:25 +00:00
refactor script.py
This commit is contained in:
15
script.py
15
script.py
@@ -1,24 +1,22 @@
|
|||||||
import pyautogui as pgui
|
import pyautogui as pgui
|
||||||
import time
|
import time
|
||||||
import keyboard as kb
|
import keyboard as kb
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
quit = False
|
|
||||||
|
|
||||||
# Enter the name of your browser, based on the name of its icon image.
|
# 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:
|
if browser_loc:
|
||||||
pgui.moveTo(browser_loc, duration=0.2)
|
pgui.moveTo(browser_loc, duration=0.2)
|
||||||
time.sleep(0.2)
|
|
||||||
pgui.click()
|
pgui.click()
|
||||||
# Change the time depending on how long it takes to open your browser
|
# Change the time depending on how long it takes to open your browser
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
else:
|
else:
|
||||||
print("Browser icon not found.")
|
print("Browser icon not found.")
|
||||||
exit()
|
sys.exit('closing script')
|
||||||
|
|
||||||
pgui.hotkey('ctrl', 't')
|
pgui.hotkey('ctrl', 't')
|
||||||
|
|
||||||
@@ -29,12 +27,11 @@ pgui.press("enter")
|
|||||||
# change depending on how long it takes to load yt
|
# change depending on how long it takes to load yt
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
while not quit:
|
while True:
|
||||||
|
|
||||||
if kb.is_pressed('q'):
|
if kb.is_pressed('q'):
|
||||||
print(':(')
|
print(':(')
|
||||||
quit = True
|
break
|
||||||
continue
|
|
||||||
|
|
||||||
opt_loc = pgui.locateCenterOnScreen('img/options.png', confidence=0.8)
|
opt_loc = pgui.locateCenterOnScreen('img/options.png', confidence=0.8)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user