Skip to content

Instantly share code, notes, and snippets.

@aliboy08
Last active August 16, 2025 12:58
Show Gist options
  • Save aliboy08/2b3a1d80cedc9daaec0ac5ccae474be5 to your computer and use it in GitHub Desktop.
Save aliboy08/2b3a1d80cedc9daaec0ac5ccae474be5 to your computer and use it in GitHub Desktop.
youtube skip ads python script (2nd monitor)
# import keyboard
import pyautogui
import time
import mss
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'F:\Tesseract-OCR\tesseract.exe'
# def get_pos():
# x, y = pyautogui.position()
# print('X: '+str(x)+' Y: '+str(y))
def skip():
x, y = pyautogui.position()
pyautogui.moveTo(3762, 804)
pyautogui.click()
print('skip')
pyautogui.moveTo(x, y)
def check():
file = screenshot()
sc = cv2.imread(file)
text = pytesseract.image_to_string(sc)
if "skip" in text:
skip()
print('found')
def screenshot():
with mss.mss() as sct:
monitor = {"top": 780, "left": 3700, "width": 120, "height": 60}
output = "sc.png".format(**monitor)
sct_img = sct.grab(monitor)
mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)
return output
# keyboard.add_hotkey('p', get_pos)
# keyboard.add_hotkey('q', screenshot)
# keyboard.wait('esc')
# X: 3762 Y: 804 # click pos
while True:
check()
print('checking...')
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment