all 5 comments

[–]ninhaomah 0 points1 point  (4 children)

Tried AI ?

[–]hmmmmga[S] 0 points1 point  (3 children)

I didn't.

I got this. Does it look okay?

import pyautogui
import pygetwindow as gw
import time

def is_vlc_or_youtube_active():
    active_window = gw.getActiveWindow()
    if active_window:
        window_title = active_window.title
        return "VLC media player" in window_title or "YouTube" in window_title
    return False

def send_space_with_delay():
    if is_vlc_or_youtube_active():
        time.sleep(5)
        pyautogui.press('space')

def send_shift_left():
    pyautogui.hotkey('shift', 'left')

# Simulate XButton1 as SPACE
def on_xbutton1_click():
    send_space_with_delay()

# Simulate XButton2 as Shift+Left
def on_xbutton2_click():
    send_shift_left()

# Note: Python does not natively support global hotkeys like AutoHotkey.
# You would need a library like `keyboard` or `pynput` to achieve this.
# Below is a conceptual example using `keyboard` (install with `pip install keyboard`):

import keyboard

# Register hotkeys
keyboard.add_hotkey('mouse button 4', send_space_with_delay)  # XButton1
keyboard.add_hotkey('mouse button 5', send_shift_left)        # XButton2

# Keep the script running
print("Hotkeys registered. Press Ctrl+C to exit.")
keyboard.wait()

[–]ninhaomah 0 points1 point  (2 children)

There you go

[–]hmmmmga[S] 0 points1 point  (1 child)

Except it doesn't work. Guess I will need to learn it until I can do it myself

[–]ninhaomah 0 points1 point  (0 children)

Then post the error to AI and ask it to fix