VLC Player URI Scheme
Posted: 06 Mar 2019, 05:38
Thought I'd share this here in case someone else was looking to do something similar.
This adds a VLC:// URI scheme and forwards the URI to VLC player.
Place the script in a safe location where you won't accidentally delete it then run it to set/remove the registry entries.
You can test it by going to VLC://<YOUR-VIDEO-URL-HERE> in your browser.
This adds a VLC:// URI scheme and forwards the URI to VLC player.
Place the script in a safe location where you won't accidentally delete it then run it to set/remove the registry entries.
You can test it by going to VLC://<YOUR-VIDEO-URL-HERE> in your browser.
Code: Select all
#NoEnv
#NoTrayIcon
#SingleInstance, Ignore
URL := RegExReplace(A_Args[1], "i)^VLC:\/\/(.+)", "$1")
RegExMatch(A_WinDir, "([^:]+)", Drive)
loop, 2
{
FullPath := % Drive ":\Program Files" (A_Index > 1 ? " (x86)" : "") "\VideoLAN\VLC\VLC.exe"
if (FileExist(FullPath))
{
VLC := FullPath
}
}
if (!URL)
{
if (!A_IsAdmin)
{
try
{
Run, % "*RunAs """ (A_IsCompiled ? A_ScriptFullPath : A_AhkPath) """" (A_IsCompiled ? "" : " /restart """ A_ScriptFullPath """")
}
catch ex
{
}
return
}
RegRead, RegValue, % "HKEY_CLASSES_ROOT\VLC\Shell\Open\Command"
RegVLC := """" (A_IsCompiled ? A_ScriptFullPath : A_AhkPath) """ " (A_IsCompiled ? "" : """" A_ScriptFullPath """ ") """%1"""
if (RegVLC == RegValue)
{
RegDelete, % "HKEY_CLASSES_ROOT\VLC\"
}
else
{
RegWrite, % "REG_SZ", % "HKEY_CLASSES_ROOT\VLC", % "", % "URL:VLC Protocol"
RegWrite, % "REG_SZ", % "HKEY_CLASSES_ROOT\VLC", % "URL Protocol", % ""
RegWrite, % "REG_SZ", % "HKEY_CLASSES_ROOT\VLC\DefaultIcon", % "", % """" (VLC ? VLC : (A_IsCompiled ? A_ScriptFullPath : A_AhkPath)) """,0"
RegWrite, % "REG_SZ", % "HKEY_CLASSES_ROOT\VLC\Shell\Open\Command", % "", % RegVLC
}
MsgBox, % "VLC URI scheme has been " (RegVLC == RegValue ? "removed" : "set") "."
return
}
if (RegExMatch(URL, "^\w+:\/\/"))
{
if (VLC)
{
Run, % """" VLC """ " Format("""{1}""", URL), , , PID
WinWait, % "ahk_pid" PID
WinActivate, % "ahk_pid" PID
}
}