TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Open youtube link on any browser & play using autohotkey😎

    Example Commands
    1
    1
    5
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • trinibT
      trinib
      last edited by

      • Requires Autohotkey (v2.0).
      • Create ahk file, enter code:
      #Requires AutoHotkey v2.0
      
      ;–– Settings ––
      videoURL := "PUT_URL_HERE"
      
      ;–– Locate Browser (Firefox in this examaple) ––
      path64 := A_ProgramFiles . "\Mozilla Firefox\firefox.exe"
      path86 := A_ProgramFiles . " (x86)\Mozilla Firefox\firefox.exe"
      if FileExist(path64)
          firefoxPath := path64
      else if FileExist(path86)
          firefoxPath := path86
      else {
          MsgBox("Could not find firefox.exe.", "Error")
          ExitApp()
      }
      
      ;–– Open in a new tab ––
      Run( Format('{} -new-tab "{}"', firefoxPath, videoURL) )
      
      ;–– Wait for YouTube tab/window ––
      SetTitleMatchMode(2)
      if !WinWait("YouTube", "", 10) {
          MsgBox("YouTube window not found.", "Error")
          ExitApp()
      }
      
      ;–– Maximize & focus ––
      hWnd := WinExist("YouTube")
      WinMaximize(hWnd)
      WinActivate(hWnd)
      WinWaitActive(hWnd, "", 5)
      
      ;–– Let it load & play ––
      Sleep(7000)
      Send("{Space}")
      
      ExitApp
      
      • In triggercmd add new command.
      • Command - location of file(C:\Users\Admin\Desktop\yourfile.ahk)

      LINUX(Requires X11, does not work with Wayland yet) - https://github.com/phil294/AHK_X11
      Code (have not tested):

      #!/usr/bin/env ahk_x11
      #NoEnv
      #SingleInstance force
      
      ;–– Settings ––
      playlistURL = PUT_URL_HERE
      
      ;–– Open in a new tab of your default Firefox ––
      ; The --new-tab flag will reuse an existing window if there is one.
      Run firefox --new-tab "%playlistURL%"
      
      ;–– Wait (up to 10s) for any window with β€œYouTube” in its title ––
      WinWait YouTube,,,10
      if ErrorLevel
      {
          MsgBox YouTube window not found.
          ExitApp
      }
      
      ;–– Maximize & focus ––
      WinMaximize YouTube
      WinActivate YouTube
      WinWaitActive YouTube,,,5
      
      ;–– Give time for the page to load ––
      Sleep 7000
      
      ;–– Toggle play/pause via Space ––
      Send {Space}
      
      ExitApp
      
      • chmod +x yourfile.ahk
      1 Reply Last reply Reply Quote 0
      • First post
        Last post