youtube background ahk
;play/pause youtube video in background (Chrome)
#Persistent
#NoEnv
#SingleInstance, Force
DetectHiddenWindows, On
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2
controlID := 0
return
#IfWinNotActive, ahk_exe dragon.exe
ctrl & space::
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome
ControlFocus,,ahk_id %controlID%
IfWinExist, YouTube
{
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
}
ControlSend, , ^1, Google Chrome
Loop
{
IfWinExist, YouTube
{
break
}
ControlSend, ,{Control Down}{Tab}{Control Up}, Google Chrome
Sleep, 150
}
Sleep, 50
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
#IfWinNotActive