I wish to open an Youtube video in VLC Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
rapino
Posts: 5
Joined: 25 Jul 2020, 11:09

I wish to open an Youtube video in VLC

25 Jul 2020, 11:18

My idea is to press Ctrl+Shift+V with an youtube tab open in chrome, then it will open the video in VLC, with the minimal view and fixed, like an Picture-in-Picture feature. I also want the tab to close after i press the hotkey. Sometimes the code below work, but not always.

Code: Select all

#IfWinActive, ahk_exe Chrome.exe
^+v::
Send, !d
ClipWait, 2
OldClipboard:= Clipboard
    Clipboard := ""
    Send ^c
    ClipWait, 1
    if !ErrorLevel
   {
      Query := Clipboard
   }
FixString = %clipboard%
StringReplace, FixString, FixString,https ,http: //  Broken Link for safety
Clipboard := FixString
ControlSend, Chrome_AutocompleteEditView1, <text>
Send, ^w
Sleep 100
Run C:\Program Files\VideoLAN\VLC\vlc.exe --qt-minimal-view  --no-qt-video-autoresize --autoscale --video-on-top %clipboard%
Sleep 400
    Clipboard:= OldClipboard
return

English is not my first language, so please ask if there is something not clear. Thank you :)
teadrinker
Posts: 1897
Joined: 29 Mar 2015, 09:41
Contact:

Re: I wish to open an Youtube video in VLC  Topic is solved

25 Jul 2020, 12:31

This should work:

Code: Select all

#IfWinActive, ahk_exe Chrome.exe
^+v::
   OldClipboard := ClipboardAll
   Clipboard := ""
   Send, !d
   Sleep, 100
   Send ^c
   ClipWait, 1
   if ErrorLevel
      Return
   Send, ^w
   URL := Clipboard
   Sleep, 50
   Clipboard := OldClipboard
   Run C:\Program Files\VideoLAN\VLC\vlc.exe --qt-minimal-view --no-qt-video-autoresize --autoscale --video-on-top %URL%
   Return
User avatar
flyingDman
Posts: 869
Joined: 29 Sep 2013, 19:01

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 12:44

Are you specifically interested in using VLC or is your goal to have a picture-in-picture rendering of a youtube video? The reason is that AHK allows you to play a video natively (through an imbedded ActiveX Explorer control). Here is an example of a Webcam of Amsterdam:

Code: Select all

id=hBnhSxlL9So                                                         ; code is embedded in the url

url = https://www.youtube.com/embed/%id%?autoplay=1
Fix := True
width := a_screenwidth / 2
height := a_screenheight / 2
gui, margin, 0,0
gui, -caption -DPIScale
 
Prev := FixIE()
Gui Add, ActiveX, x0 y0 w%width% h%height% vWB, Shell.Explorer
WB.Navigate(URL)
FixIE(Prev)
Gui,show, x%width% y0 w%width% h%height%, YT
return

esc::
Guiclose:
WB.Document.close
WB := ""
exitapp

FixIE(Version=0, ExeName="")												; credit GeekDude
{
	static Key := "Software\Microsoft\Internet Explorer"
	. "\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
	, Versions := {7:7000, 8:8888, 9:9999, 10:10001, 11:11001}
	
	if Versions.HasKey(Version)
		Version := Versions[Version]
	
	if !ExeName
	{
		if A_IsCompiled
			ExeName := A_ScriptName
		else
			SplitPath, A_AhkPath, ExeName
	}
	
	RegRead, PreviousValue, HKCU, %Key%, %ExeName%
	if (Version = "")
		RegDelete, HKCU, %Key%, %ExeName%
	else
		RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, %Version%
	return PreviousValue
}
Size and location can be customized. Esc to exit.
Last edited by flyingDman on 25 Jul 2020, 13:15, edited 1 time in total.
teadrinker
Posts: 1897
Joined: 29 Mar 2015, 09:41
Contact:

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 12:56

flyingDman wrote:

Code: Select all

GuiControl,, URL, % wb.LocationUrl
There is no such control in your GUI. :)
User avatar
flyingDman
Posts: 869
Joined: 29 Sep 2013, 19:01

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 13:17

You are correct. Correction made above.
teadrinker
Posts: 1897
Joined: 29 Mar 2015, 09:41
Contact:

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 13:47

Also I'm not sure that the FixIE() call is correct. It writes 0 in the register key, but should 11001 or 11000.
garry
Posts: 2456
Joined: 22 Dec 2013, 12:50

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 14:55

@flyingDman @teadrinker thank you for the examples
FlyingDman, your script works for me without FixIE , it's because it has once already written something to registry (?)

Code: Select all

id=hBnhSxlL9So 
url = https://www.youtube.com/embed/%id%?autoplay=1
width  := a_screenwidth/2,height:= a_screenheight/2
gui, margin, 0,0
gui, -caption -DPIScale
Gui Add, ActiveX, x0 y0 w%width% h%height% vWB, Shell.Explorer
WB.Navigate(URL)
Gui,show, x%width% y0 w%width% h%height%, YT
return
;--------
esc::
Guiclose:
WB.Document.close
WB := ""
exitapp
;--------------
EDIT : works now with latest version vlc.exe 3.0.11 64-bit win10
I had no succes to play youtube with vlc.exe ( see short video picture ) , Hitchcock or other video extensions are OK

Code: Select all

url:="http://www.cheeseheadhosting.us/downloads/golden%20age%20of%20television%20vault%201/1955%20alfred%20hitchcock%20presents/Alfred%20Hitchcock%20Presents%203x06%20Reward%20To%20Finder.avi"
;url:="https://www.youtube.com/watch?v=2SZvhUVXlE4"
;url:="https://www.youtube.com/embed/l9lw-zQcZ58?autoplay=1"
Run,%a_programfiles%\VideoLAN\VLC\vlc.exe --qt-minimal-view --no-qt-video-autoresize --autoscale --video-on-top "%url%"
return
Last edited by garry on 25 Jul 2020, 15:25, edited 1 time in total.
garry
Posts: 2456
Joined: 22 Dec 2013, 12:50

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 14:58

example YoutubePlay with DropDownList

Code: Select all

;- Internetbrowser play also Youtube-Video / with DropDownList 
;- Modified=20200408
;- Created =20200217
#warn
#NoEnv  
SendMode Input 
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode 2
SetBatchLines, -1
CoordMode, Mouse , Relative  ;- GUI
DetectHiddenWindows, On
filename1=InternetBrowser  
Gui,3:default
Gui,3: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,3:color,black,black
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;- maybe change fontsize
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
  Gui,3:Font,s14 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
if (wa=1920)
 Gui,3:Font,s10 cYellow,Lucida Console
;=============================================================
xxa=Shell.Explorer      ;- IExplorer
;xxa=Mozilla.Browser    ;- Mozilla Firefox
transform,s,chr,32
url:=""
h2:=""
global url,h2
;------------
;xxvd=https://www.youtube.com
xxvd=https://invidio.us
e5x=
(Ltrim comments join|
Lilian de Celis -ElRelicario YT                   ,https://www.youtube.com/embed/eKZhI2r9J8U?autoplay=1
Lilian de Celis -A hierro muere YT                ,https://www.youtube.com/embed/2SZvhUVXlE4?autoplay=1
Gloria Lasso Etranger au paradies                 ,%xxvd%/watch?v=l9lw-zQcZ58&autoplay=1
Li xiang lan -Ye lai xiang                        ,%xxvd%/watch?v=iR0w0mWB3uA&autoplay=1
Grace Chang Ge Lan - Calypso                      ,%xxvd%/watch?v=ZIfpCLrjXVU&autoplay=1
Leonore Veenemans-Kom terug                       ,%xxvd%/watch?v=mgcxgK1uXj8&autoplay=1
Vera Ellen - Three little words 1950              ,%xxvd%/watch?v=pd6suTj5wQ0&autoplay=1
Jim Reeves - I love you because                   ,%xxvd%/watch?v=qit_HikDGxU&autoplay=1
Julie Andrews-I could have danced all night       ,%xxvd%/watch?v=av_79tvxTFA&autoplay=1
Sumi Yo - La Paloma                               ,%xxvd%/watch?v=ulS3pklaoz4&autoplay=1
Shin Yeon Ah-La Paloma                            ,%xxvd%/watch?v=OCeSmYAn_9E&autoplay=1
%s%
)
;--------
x:=(wa*.2)/xx,y:=(ha*.1)/xx,h:=(ha*2.4)/xx,w:=(wa*35)/xx
Gui,3: Add, Edit, x%x% y%y% w%w% h%h%  vURL,
x:=(wa*35.7)/xx,w:=(wa*1.5)/xx
Gui,3: Add, Button,x%x% y%y% w%w% h%h%  gBrB, <
x:=(wa*38)/xx,
Gui,3: Add, Button,x%x% y%y% w%w% h%h%  gBrF, >
x:=(wa*40)/xx,
Gui,3: Add, Button,x%x% y%y% w%w% h%h% Default gA1, Go
x:=(wa*44)/xx,h:=(ha*25)/xx,w:=(wa*20)/xx
Gui,3:Add,DDL,x%x% y%y% w%w% h%h% cBlack vUrlDDL gAA,%e5x%
x:=(wa*.2)/xx,y:=(ha*3)/xx,h:=(ha*60)/xx,w:=(wa*65)/xx
Gui,3: Add, ActiveX, w%w% h%h% x%x% y%y% vWB,%xxa%
;--------
WB.Silent := True
ComObjConnect(WB, WB_events)    ;- Connect WB's events to the WB_events class object.
;--------
x:=(wa*.2)/xx,y:=(ha*.2)/xx,h:=(ha*70)/xx,w:=(wa*67)/xx
Gui,3:show,x%x% y%y% w%w% h%h%,%filename1%
;--------
GuiControl,3: ChooseString,urlddl,Grace
gosub,aa
return
;----------------------------------------------------

;-----------------------------------------------------
3Guiescape:
3GuiClose:
WB.Document.close
WB := ""
exitapp
;-----------------------------------------------------
aa:
Gui,3: submit, nohide
h1:=""
h2:=""
if urlDDL<>
   {
   StringSplit,h,urlddl, `,
   Guicontrol,3:,url,%h2%
   WB.Navigate(h2)
   }
return
;----------------------------------------------------------------
a1:
Gui,3: Submit, NoHide
try 
 WB.Navigate(URL)
catch e
 {
 xxx:=e.Message
 msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
 return
 }
return
;-----------
Brb:
try{WB.GoBack()
}catch e{
;xxx:=e.Message
return
}
return
;--------------------
BrF:
try{WB.GoForward()
}catch e{
;xxx:=e.Message
return
}
return
;-------------------
class WB_events
{
NavigateComplete2(wb, NewURL)
  {
  GuiControl,3:, URL, %NewURL%
  }
}
;========================= END SCRIPT ==================================
teadrinker
Posts: 1897
Joined: 29 Mar 2015, 09:41
Contact:

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 15:11

garry wrote: I had no succes to play youtube with vlc.exe
My vlc.exe plays both of your URLs.
garry
Posts: 2456
Joined: 22 Dec 2013, 12:50

Re: I wish to open an Youtube video in VLC

25 Jul 2020, 15:24

@teadrinker thank you it works now , downloaded latest version vlc.exe 3.0.11 64-bit win10
rapino
Posts: 5
Joined: 25 Jul 2020, 11:09

Re: I wish to open an Youtube video in VLC

26 Jul 2020, 14:22

@teadrinker Thank you, this works perfectly

Return to “Ask For Help”

Who is online

Users browsing this forum: account1337, boiler, RafaelCardoso, Renegaduh, Xtra and 39 guests