0

The context: Sometimes I am playing a fullscreen game on one monitor while watching a video on the other. Oftentimes the game I play has no "fullscreen window" mode. (right now I'm playing one that only has 640x480 fullscreen!)

The problem: Occasionally something happens in the video that I miss because I'm focused on the game, and I want to rewind the video to see it. For VLC, this is easy, because I can set up a global keybind for seeking. However, for YouTube, I have no choice but to hit alt-tab, wait while Windows takes my primary monitor out of fullscreen mode, focus the relevant browser window, hit the left key, then return to the game and wait for it to go fullscreen again. This is immensely annoying.


The goal: What I want to be able to do is to hit a key combination while playing and have the YouTube video seek backwards, without focus ever leaving the fullscreen game.

I tried the following AutoHotKey script:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

CheckVideoSeekId() {
  global VIDEO_SEEK_WINDOW_ID

  if (VIDEO_SEEK_WINDOW_ID = "" or not WinExist("ahk_id" VIDEO_SEEK_WINDOW_ID)) {
    ToolTip, No window set for video control.
    SetTimer, RemoveToolTip, -4000
    SoundPlay, *-1  ; plays the system "beep" sound
    return 0
  }
  return 1
}

RemoveToolTip() {
  ToolTip
}

^!+Insert::
  VIDEO_SEEK_WINDOW_ID := WinExist("A")
  ToolTip, Active window set for video control.
  SetTimer, RemoveToolTip, -4000
  return

^!+End::
  if (CheckVideoSeekId()) {
    ControlSend, , {Left}, ahk_id %VIDEO_SEEK_WINDOW_ID%
  }
  return

^!+PgDn::
  if (CheckVideoSeekId()) {
    ControlSend, , {Right}, ahk_id %VIDEO_SEEK_WINDOW_ID%
  }
  return

These are intended to make it so that you can press Ctrl+Alt+Shift+Insert once while Youtube is focused, and then be able to press Ctrl+Alt+Shift+{End,PgDn} while any window is focused in order to seek.

Unfortunately... Ctrl+Alt+Shift+{End,PgDn} do not appear to function at all when a window besides the browser is focused... and even when the browser IS focused, each press of the key combinations seems to have only a 20% random chance (!!) of actually seeking the video. (and only in Chrome; for Firefox and Edge, it just doesn't work at all!)

(Note: I tried sending other keys like Up/Down with other tabs active and it seems like the browser receives the keys just fine; the issue is specifically when the keys are supposed to control YouTube's player)

How do?


(this question is tagged "autohotkey," but the solution does not need to involve AutoHotKey; I just need something that works on Windows)

0

The letter "J" equals go back 10 seconds in YouTube (I love keyboard shortcuts). I admit that I do not understand all your HotKey code but it definitely looks impressive. I hope this helps you find success.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.