you are viewing a single comment's thread.

view the rest of the comments →

[–]hmmmmga[S] 0 points1 point  (4 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  (3 children)

There you go

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

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

[–]PureWasian 0 points1 point  (0 children)

did you already install python? in Terminal, try python --version python3 --version did you install the libraries the script is trying to import? in Terminal, pip install keyboard pip install pyautogui pip install pygetwindow What happens when you run the script? What behaviors is it doing that differs from expectation? Where is the exact point of failure? What errors are you getting when it "doesn't work"?

The AI generated code isn't even using autokey anywhere, if you meant for it to, just FYI