[ PS. If this doesn't sound offensive, I am more than happy to pay for your time to help me, as I understand this is a lot of works. Please pm me please. Thank you very much!! ]
Someone helped me with the code below (I learned later that I should record names of those good Samaritans) to stop and play a YouTube video running on a Chrome tab while using a different program and without having to focus on that Chrome window/tab.
But I may have more than one YouTube tabs opening...
Could you please help me with changing it so it'll work with Firefox instead, or only the Chrome YouTube tab that has a certain keyword(s), or VLC,..?
It also doesn't work sometimes... I don't know why...
Also, when I tried changing to have ^w to send "Left" (to rewind 10 seconds) it didn't work
Thank you very much!!
Code: Select all
;============================== Start Auto-Execution Section ==============================
; Keeps script permanently running
#Persistent
; Avoids checking empty variables to see if they are environment variables
; Recommended for performance and compatibility with future AutoHotkey releases
#NoEnv
; Ensures that there is only a single instance of this script running
#SingleInstance, Force
;Determines whether invisible windows are "seen" by the script
DetectHiddenWindows, On
; Makes a script unconditionally use its own folder as its working directory
; Ensures a consistent starting directory
SetWorkingDir %A_ScriptDir%
; sets title matching to search for "containing" isntead of "exact"
SetTitleMatchMode, 2
;sets controlID to 0 every time the script is reloaded
controlID := 0
return
;============================== Main Script ==============================
#IfWinNotActive, ahk_exe chrome.exe
^q::
; Gets the control ID of google chrome
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome
; Focuses on chrome without breaking focus on what you're doing
ControlFocus,,ahk_id %controlID%
; Checks to make sure YouTube isn't the first tab before starting the loop
; Saves time when youtube is the tab it's on
IfWinExist, YouTube
{
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
}
; Sends ctrl+1 to your browser to set it at tab 1
ControlSend, , ^1, Google Chrome
; Starts loop to find youtube tab
Loop
{
IfWinExist, YouTube
{
break
}
;Scrolls through the tabs.
ControlSend, ,{Control Down}{Tab}{Control Up}, Google Chrome
; if the script acts weird and is getting confused, raise this number
; Sleep, is measures in milliseconds. 1000 ms = 1 sec
Sleep, 150
}
Sleep, 50
; Sends the K button to chrome
; K is the default pause/unpause of YouTube (People think space is. Don't use space!
; It'll scroll you down the youtube page when the player doesn't have focus.
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
#IfWinNotActive
;============================== End Script ==============================