- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
Latest commit
66 lines (56 loc) · 2.05 KB
/
Copy pathrun.py
File metadata and controls
66 lines (56 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
importtime
importpyautogui
importwebbrowser
defswitch_subscription(channel_name):
chrome_path='C:/Program Files/Google/Chrome/Application/chrome.exe %s'
# webbrowser.get(chrome_path).open(url4)
webbrowser.open_new_tab("https://youtube.com")
#open new tab
# pyautogui.hotkey("ctrl", "t")
time.sleep(5)
x, y=pyautogui.locateCenterOnScreen("yt_search_btn.png", confidence=0.5)
pyautogui.moveTo(x, y, 1)
pyautogui.click()
pyautogui.write(channel_name)
pyautogui.hotkey("enter")
time.sleep(3)
x, y=pyautogui.locateCenterOnScreen("mr_beast_logo.png", confidence=0.5)
pyautogui.moveTo(x, y, 1)
pyautogui.click()
time.sleep(2)
# Attempt to locate the first image
try:
x, y=pyautogui.locateCenterOnScreen("unsuscribe_btn.png", confidence=0.8)
exceptpyautogui.ImageNotFoundException:
# If the first image is not found, try the second image
try:
x, y=pyautogui.locateCenterOnScreen("subscribe_btn.png", confidence=0.8)
exceptpyautogui.ImageNotFoundException:
print("Neither image was found on the screen.")
else:
# If the second image is found, move to and click it
pyautogui.moveTo(x, y, 1)
pyautogui.click()
time.sleep(2)
pyautogui.hotkey("ctrl", "w")
else:
# If the first image is found, move to and click it
pyautogui.moveTo(x, y, 1)
pyautogui.click()
time.sleep(1)
unsuscribe_btn_menu=pyautogui.locateCenterOnScreen("unsuscribe_btn_menu.png", confidence=0.8)
x, y=unsuscribe_btn_menu
pyautogui.moveTo(x, y, 1)
pyautogui.click()
time.sleep(1)
unsuscribe_btn_menu_dialog=pyautogui.locateCenterOnScreen("unsuscribe_btn_menu_dialog.png", confidence=0.7)
x, y=unsuscribe_btn_menu_dialog
pyautogui.moveTo(x, y, 1)
pyautogui.click()
time.sleep(2)
pyautogui.hotkey("ctrl", "w")
# Run the function every minute
whileTrue:
channel_name=pyautogui.prompt(text="",title="Enter channel name")
switch_subscription("channel_name")
time.sleep(60)