script to full screen YouTube videos

Get help with using AutoHotkey and its commands and hotkeys
kmcintyre
Posts: 10
Joined: 29 Mar 2014, 18:35

script to full screen YouTube videos

22 Jul 2017, 16:04

Hello,

I'm visually impaired and use a lot of AHK scripts to aid in my use of my computer. But I have a problem and can use some help...

One thing I would love to automate is finding and clicking the button at the far right of the YouTube video player's control bar. I'm pretty sure there is no Windows handle or id for this control. And I'm pretty sure that I'd need to do an http Send with some command string to ask YouTube to go full screen. But those are just educated guesses,..

If any of you young, super studs can help an old blind guy out with a script to automate taking YouTube videos full screen, I'd be greatly appreciative...

(I have the same issue with Vimeo. I'm guessing if I can see how to do it with YouTube I'll be able to figure out Vimeo...)

Thanks in advance!

Keith
User avatar
jeeswg
Posts: 4973
Joined: 19 Dec 2016, 01:58
Location: UK

Re: script to full screen YouTube videos

22 Jul 2017, 17:28

This is the most annoying problem ever. Pressing f works to get fullscreen in Mozilla Firefox and Google Chrome, but not in Internet Explorer.

This works for YouTube in Internet Explorer, but if anyone has any other ideas or knowledge on the subject, I would like to know anything I can about this problem, thanks.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Re. annoying, in the UK at least, when watching playlists, YouTube kept playing the same 3 mini-Tyler Oakley adverts and 1 Lilly Singh advert constantly. This was really awful and so I set up a script to mute YouTube the second I heard one of those ads come on.

==================================================

I couldn't get Vimeo to work, I tried things like:

Code: [Select all] [Download] GeSHi © Codebox Plus

	oWB.document.getElementsByClassName("fullscreen").item[0].focus()
oWB.document.getElementsByClassName("fullscreen").item[0].click()
oWB.document.getElementsByClassName("fullscreen-icon").item[0].focus()
oWB.document.getElementsByClassName("fullscreen-icon").item[0].click()

Like YouTube, f works to set fullscreen on, on Mozilla Firefox and Google Chrome, but doesn't work on Internet Explorer 11.
Last edited by jeeswg on 22 Jul 2017, 18:42, edited 1 time in total.
kmcintyre
Posts: 10
Joined: 29 Mar 2014, 18:35

Re: script to full screen YouTube videos

22 Jul 2017, 18:20

Well that's totally awesome! I have been using Edge just because I like it and it's the default. But I have chrome and Firefox too.

Hopefully someone will add to the discussion with a workaround for IE 11 and/or Edge...

I used to be a programmer. I could follow your code quite easily. Thanks!

Keith
User avatar
jeeswg
Posts: 4973
Joined: 19 Dec 2016, 01:58
Location: UK

Re: script to full screen YouTube videos

11 Aug 2017, 08:31

It turns out that with YouTube you can double-click on the video to view it in fullscreen, but I am having trouble trying to invoke double-click on a web element, if anyone has any ideas.

E.g. *not* working, it reacts (toggles play/pause) but doesn't invoke fullscreen:

Code: [Select all] [Download] GeSHi © Codebox Plus

	oWB.document.getElementById("movie_player").click()
Sleep 100
oWB.document.getElementById("movie_player").click()

(dblclick and doubleclick didn't work.)

==================================================

This is a version of the script above for YouTube, but which closes the notification bar via Acc.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by jeeswg on 11 Aug 2017, 14:44, edited 2 times in total.
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: script to full screen YouTube videos

11 Aug 2017, 11:58

Nice jeeswg!

Just 2 tips:
  • You can use oWB.hwnd instead of WinGet, hWnd, ID, ahk_class IEFrame
  • You can use oAcc := oAcc.accChild(4) instead of oAcc := Acc_Get("Object", "4.4", 0, "ahk_id " hCtl)

BTW, the F key works for me in Edge browser.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: script to full screen YouTube videos

11 Aug 2017, 13:32

Wasn't it F11 for all other IEs ??
User avatar
jeeswg
Posts: 4973
Joined: 19 Dec 2016, 01:58
Location: UK

Re: script to full screen YouTube videos

11 Aug 2017, 14:47

@tmplinshi: Thanks. It seems I left some extra lines in, from debugging, it's fixed now.

@BoBo: F11 sets fullscreen for Internet Explorer, f or double-click sets fullscreen for the YouTube video.
User avatar
Masonjar13
Posts: 1389
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: script to full screen YouTube videos

12 Aug 2017, 00:35

This may or may not work..

Code: [Select all] [Download] GeSHi © Codebox Plus

oWB.document.dblclk.createEventObject()
oWB.document.dblclk.eventType:="dblclick"
oWB.document.eventName="dblclick"

; call it

; oWB.document.getElementsByClassName("ytp-fullscreen-button ytp-button").item[0].fireEvent("on" . oWB.document.dblclk.eventType, oWB.document.dblclk)
oWB.document.getElementById("movie_player").fireEvent("on" . oWB.document.dblclk.eventType, oWB.document.dblclk)

More likely to work.

Code: [Select all] [Download] GeSHi © Codebox Plus

; oWB.navigate("javascript:var dblclk=document.createEventObject();dblclk.eventType='dblclick';document.getElementsByClassName('ytp-fullscreen-button ytp-button').item[0].fireEvent('on'+dblclk.eventType,dblclk);")
oWB.navigate("javascript:var dblclk=document.createEventObject();dblclk.eventType='dblclick';document.getElementById('movie_player').fireEvent('on'+dblclk.eventType,dblclk);")

Anyone know a way to directly execute JS via COM?

Return to “Ask For Help”

Who is online

Users browsing this forum: anobayan, Coder, newbieforever, shgilad81 and 95 guests