Open youtube link on any browser & play using autohotkeyπ
-
- 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register Login