Hi everyone
Just sitting around here tonight, conjuring up some ideas on what sort of code to tackle next.
Let's say we have multiple Google Chrome windows (not tabs) open, and a few of them are on Youtube.
One of them is playing a video. The rest of them are also on videos, but are not playing right now.
Next, say we open up a notepad window or something and begin typing anything into it. The Chrome window which is playing the video is now inactive.
Is there a possibile way to send a keystroke to this particular inactive window (in order to play/pause) the video? Can there be a way to isolate which exact Chrome window is playing content and then send a keystroke to it.
The only way I can think of is to loop through all Youtube windows, and send the appropriate keystroke to all those windows one-by-one. The problem is, it would stop the window which is playing the video, but then also start playing all the other ones.
This is just food for thought. Just for fun. If no replies it's cool. Just thought maybe somebody already had something like this in their collection of scripts
Send keys to YouTube window which is playing music/video
-
- Posts: 844
- Joined: 21 Dec 2015, 02:34
Re: Send keys to YouTube window which is playing music/video
I imagine that there might be a browser call or way to use Chrome.ahk to accomplish this. One simple alternative: if you use AHK to activate the initial play action, then you could retrieve the window's ID at that time, and you would then know which window to target for the toggle.
Code: Select all
F3:: ; Toggle play after initial play has occurred (see below)
If WinExist(chromePlaying)
WinExist("A")
Else Return
WinActivate, %chromePlaying%
Send {Space}
WinActivate
Return
#IfWinActive ahk_exe chrome.exe
F4:: ; Initial play
WinGetActiveTitle, wTitle
If Instr(wTitle, "YouTube") {
chromePlaying := "ahk_id " WinExist("A")
Send {Space}
} Else MsgBox, 48, Error, YouTube tab is not active.
Return
-
- Posts: 844
- Joined: 21 Dec 2015, 02:34
Re: Send keys to YouTube window which is playing music/video
ah-ha! awesome! that works just as well
Who is online
Users browsing this forum: mmflume and 136 guests