i was using simple version of this script (v.1) for the old site but now video frame changes size like crazy
tough job as it is, i managed to make my ahk generated window act like youtube video div manually xD maybe a brute-force-like video frame boundary pixel search would be a global solution but here it is...
usage
- open your youtube video in firefox, chrome, opera or vivaldi
- turn on youtube theater mode
- adjust size and screen placement of the video window
- open the script
makes whole screen black while we only see the youtube video frame
only works for firefox, chrome, opera & vivaldi
when there is no menu and bookmarks toolbar in any browser
opera has no sidebar
vivaldi has left panel
when on different application (working / playing) you can use video timeskip keys (arrow keys) on firefox
they will be sent to browser
double click on black areas to closeworks on multi monitors
works on win10
to start the script with a key combination anytime, you can write an always-working-script that resides in your windows Startup folder
limitations
fullscreen black background is optional, can be disabled from system tray menu
remote controls (arrow keys 5 sec video skip) only works on firefox (LoL firefox ftw)
ControlSend doesnt work on any chrome-like browser ahk_class Chrome_WidgetWin_1 even though we send to right control Chrome_RenderWidgetHostHWND1 (idk why)
( therefore if you do not want these 2 features like ever, you may just delete related lines from the code )window you want script to work on should be active (on top of everything)
or it works (or returns error) for the active youtube window
script is designed only for standard browser window
any action which will change the browser window border sizes (maximized or full screen affects title bar size...) will cause script to not work properly
about fullscreenscript isnt compatible with any kind of fullscreen unless you manually expand window to whole screen in theater mode.
even if we understand the browser is filling whole screen and even if we can get current video start coordinate with brute force search (while youtube doesnt change that top color) to get some of the init values; it seems we need some new vars and if nodes because of the system non-visible area rule change that came with snapping edges on maximized / fullscreen. apparently we need to double the whole work and code lines to have this feature. therefore fullscreen support cant be added :)
20" and below monitor users may not even need the script since fullscreen video mode may cover their needs. they may never need black area on their screen.
i dont know about anyone but 21"+ monitors provide so large picture that from the day i bought i cant watch any video on fullscreen unless im meters away. i cant use fullscreen, i need blackness on my desktop when im writing, therefore the script is shaped around that fact.
numbers
since i dont think everyone would prefer using a shortcut for the job, numbers ive found can be used in any kind of language you will work on to generate more cinematic-mode-like view (inside browser page, with button on browser screen...) but i guess there are much easier ways to get page element coordinates on different platforms xD
differences on client window sizes or toolbar placements on other browsers directly effect this kind of tool so i only made it for my usage.
you may edit the code to get no background, no input listening etc... you may edit numbers to adjust it to your browsers but you need a solid plan and tools that will make your job much easier. still takes much time, i dont encourage you to do it.
right now its working perfect, hopefully youtube doesnt change those video size rules again :)
cheers
[Edit: Updated to v.3, now supports different browsers]
Code: Select all
; youtube watcher v.3
; gtaking
; 2017 III
; Designed for YouTube Theater mode
; video window should be active
; Works on desktop
; Echoes timeskip keys to video window
; can be disabled from tray menu
; Fills background with black screen
; can be closed from tray menu
; Double click to dismiss
; for youtube videos on Firefox, Chrome, Opera & Vivaldi
; for new youtube design update
; values when there is no extra toolbars (menu bar, bookmarks toolbar etc...)
; video frame coordinate yvid : 1st non-black pixel
; browser window left column wI : 6-8
; browser window right column wII : 23-25
; browser window bot row (no scrollbar) wIII : 6-8
#NoTrayIcon
#SingleInstance, Force
#KeyHistory 0
#WinActivateForce
ListLines Off
SetBatchLines, -1
SetWinDelay, -1
SetKeyDelay, -1, -1
SendMode Input
SetTitleMatchMode, 2
arrowkeysactive := true, arrowmenuname1 := "Disable remote control", arrowmenuname2 := "Enable remote control"
Menu, Tray, Icon, accessibilitycpl.dll, 13
Menu, Tray, Tip, Youtube Watcher
Menu, Tray, NoStandard
Menu, Tray, Add, %arrowmenuname1%, Deactivate
Menu, Tray, Add, Remove Background, RemovingBlackBack
Menu, Tray, Add, Quit, Exit
Menu, Tray, Default, Quit
Menu, Tray, Icon
Gui +OwnDialogs
bid := WinExist("YouTube")
if (!bid) {
MsgBox, 0x40000, Youtube Watcher, No active YouTube window found., 1.5
ExitApp
Return
}
bid := "ahk_id " bid
WinGet, bname, ProcessName
; extra toolbars inside browser, which are narrowing page area
extrahbot := 0
; if you have different toolbar layout than script default, modify related values
; scrollbars, title bars given by the system, which are directly affecting window start / end coordinates
if (bname == "firefox.exe")
wI := 6, wII := 23, wIII := wI, yv := 141
else if (bname == "chrome.exe" )
wI := 8, wII := 25, wIII := wI, yv := 141
else if (bname == "opera.exe")
wI := 8, wII := 23, wIII := wI, yv := 137
else if (bname == "vivaldi.exe")
wI := 34, wII := 17, wIII := 0, yv := 126, extrahbot := 20
; else if (bname == "Safari.exe")
; Safari doesn't support new site at this moment
else {
MsgBox, 0x40000, Youtube Watcher, Supported browsers:`tFirefox`, Chrome`, Opera & Vivaldi., 5
ExitApp
Return
}
WinGetPos, x, y, w, h, %bid%
if (h < yv + wII + wIII) {
MsgBox, 0x40000, Youtube Watcher, YouTube window is minimized or too small, 1.5
ExitApp
Return
}
if (w <= 881 + wI + wIII) {
yvid := yv + 24
if (w <= 656 + wI + wIII) {
wvid := 426
hvid := 240
}
else if (w <= 856 + wI + wIII) {
wvid := 640
hvid := 360
}
else {
wvid := 853
hvid := 480
}
ww := w - wI - wII - wvid
if (ww > 0) {
if (mod( ww, 2)) {
ww := (ww - 1) / 2
wI += ww + 1
}
else {
ww := ww / 2
wI += ww
}
wII += ww
}
yIII := y + yvid + hvid
hIII := h - yvid - hvid
}
else {
yvid := yv
wvid := w - wI - wII
if (h < 750 + wIII) {
hvid := 480
yIII := y + yvid + hvid
hIII := h - yvid - hvid
}
else {
hv := 8 ; video render frame
; top & bottom black spaces
hvid := round( wvid / 16 * 9) + hv
yIII := y + yvid + hvid
hh := y + h - wIII - 129 - extrahbot
if (yIII > hh) {
yIII := hh
hvid := yIII - y - yvid
}
hIII := h - yvid - hvid
}
}
if (hIII < wIII + extrahbot) {
yIII := y + h - wIII - extrahbot
hIII := wIII + extrahbot
hvid := yIII - y - yvid
}
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
Gui, New, +HwndBrowserBlackBack +Owner +Disabled -Caption -SysMenu -Theme +ToolWindow
Gui, %BrowserBlackBack%: Color, black
Gui, %BrowserBlackBack%: Show, x0 y0 w%VirtualScreenWidth% h%VirtualScreenHeight% NoActivate
WinSet, Bottom, , ahk_id %BrowserBlackBack%
WinActivate, ahk_class Shell_TrayWnd
Gui, New, +HwndBrowserBlackI +Owner +Disabled -Caption -SysMenu -Theme +ToolWindow +AlwaysOnTop
Gui, %BrowserBlackI%: Color, black
Gui, %BrowserBlackI%: Show, x%x% y%y% w%w% h%yvid% NoActivate
xII := x + w - wII
yII := y + yvid
Gui, New, +HwndBrowserBlackII +Owner +Disabled -Caption -SysMenu -Theme +ToolWindow +AlwaysOnTop
Gui, %BrowserBlackII%: Color, black
Gui, %BrowserBlackII%: Show, x%xII% y%yII% w%wII% h%hvid% NoActivate
Gui, New, +HwndBrowserBlackIV +Owner +Disabled -Caption -SysMenu -Theme +ToolWindow +AlwaysOnTop
Gui, %BrowserBlackIV%: Color, black
Gui, %BrowserBlackIV%: Show, x%x% y%yII% w%wI% h%hvid% NoActivate
Gui, New, +HwndBrowserBlackIII +Owner +Disabled -Caption -SysMenu -Theme +ToolWindow +AlwaysOnTop
Gui, %BrowserBlackIII%: Color, black
Gui, %BrowserBlackIII%: Show, x%x% y%yIII% w%w% h%hIII% NoActivate
Return
LButton::
RButton::
MouseGetPos, , , id
if (id == BrowserBlackI or id == BrowserBlackII or id == BrowserBlackIII or id == BrowserBlackIV or id == BrowserBlackBack) {
melapsed := A_TickCount - mlastpressed
if (melapsed < 300 && mlastid == id && A_ThisHotkey == mlastkey)
GoSub, Exit
}
else
if (A_ThisHotkey == "LButton")
Click down
else
Click down right
mlastid := id
mlastkey := A_ThisHotkey
mlastpressed := A_TickCount
Return
~LButton Up::
~RButton Up::
Return
~Left::
~Right::
if (arrowkeysactive) and not WinActive(bid) {
StringTrimLeft, arrowkey, A_ThisHotkey, 1
ControlSend, , {%arrowkey%}, %bid%
}
Return
Deactivate:
arrowkeysactive := !arrowkeysactive
if (arrowkeysactive)
Menu, Tray, Rename, %arrowmenuname2%, %arrowmenuname1%
else
Menu, Tray, Rename, %arrowmenuname1%, %arrowmenuname2%
WinActivate, ahk_class Shell_TrayWnd
WinActivate, %bid%
Return
AddingBlackBack:
Menu, Tray, Delete, Add background
Menu, Tray, Insert, Quit, Remove background, RemovingBlackBack
Gui, %BrowserBlackBack%: Show
WinActivate, ahk_class Shell_TrayWnd
WinActivate, %bid%
Return
RemovingBlackBack:
Menu, Tray, Delete, Remove background
Menu, Tray, Insert, Quit, Add background, AddingBlackBack
Gui, %BrowserBlackBack%: Hide
WinActivate, %bid%
Return
Exit:
GuiClose:
ExitApp
Return