HI. If you take notes in Obsidian while watching Youtube videos in a browser, this AutoHotKey script will allow you to rewind, pause, or fast forward the video without taking your hands off your keyboard, as the focus automatically returns to Obsidian. (The script is tested on Windows 10)
The shortcuts are:
CTRL+J = Rewind
CTRL+K = Pause/Play
CTRL+L = Forward
This script is made for Chrome, but if you have any other browser, you have to change three lines of code. In each line where it says “ahk_exe chrome.exe” change the word chrome to msedge, vivaldi, opera, firefox or brave, depending on your browser.
This script works in the version 1.1 of AutoHotKey. It’s not tested in Version 2.
; In case you have another browser, replace where it says "chrome"
; by the name of your browser with: "msedge"; "opera", "vivaldi", "firefox" or "brave".
;CONTROLS:
;CTRL+J = Rewind
;CTRL+K = Pause/Play
;CTRL+L = Forwind
#SingleInstance Force
#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.
#InstallKeybdHook
; YOUTUBE (Microsoft-Edge)-OBSIDIAN FOCUS CHANGE: --------------------------------------
^k::YoutubePause("ahk_exe chrome.exe")
YoutubePause(title)
{
IfWinExist, %title%
WinActivate
sleep 15
Send k
sleep 15
{
IfWinExist, ahk_exe Obsidian.exe
WinActivate
}
}
return
^j::YoutubeRewind("ahk_exe chrome.exe")
YoutubeRewind(title)
{
IfWinExist, %title%
WinActivate
sleep 15
Send j
sleep 15
{
IfWinExist, ahk_exe Obsidian.exe
WinActivate
}
}
return
^l::YoutubeForwind("ahk_exe chrome.exe")
YoutubeForwind(title)
{
IfWinExist, %title%
WinActivate
sleep 15
Send l
sleep 15
{
IfWinExist, ahk_exe Obsidian.exe
WinActivate
}
}
return