user5280114
user5280114

Reputation:

Detecting ahk class of YouTube HTML5 player

I'd like to assign back and forward YouTube keyboard commands to my middle and right click mouse buttons respectively. Unfortunately, with HTML player it is not possible to differentiate the youtube video window from Firefox ahk class as I did before with flash player. I've tried MouseClick commands and simple reassigning keyboard commands to mouse but none of it worked. For some reason autohotkey couldn't be made to send no click commands to the HTML video window and I couldn't even reassign the basic functions of the mouse middle click for example, to make it work as a Left keyboard command. Anyone has an idea how to make a working autohotkey script that would enable me to turn Left and Right keyboard commands into mouse Right and Middle button clicks?

Upvotes: 0

Views: 1119

Answers (3)

Forivin
Forivin

Reputation: 15488

Like this?

#If YouTubeHtml5Active()
    RButton::Right
    MButton::Left
#If

YouTubeHtml5Active() {
    tmmBackup := A_TitleMatchMode 
    SetTitleMatchMode, RegEx
    youtubeVideoAvtive := WinActive(".+ \- YouTube \- Mozilla Firefox")
    SetTitleMatchMode, %tmmBackup%
    If youtubeVideoAvtive
        Return True
}

Upvotes: 1

user5280114
user5280114

Reputation:

I've found a simple script doing this on autohotkey forum http://www.autohotkey.com/board/topic/69720-controll-youtube-volume-with-mousewheel/, here it is, works like a charm:

SetTitleMatchMode 2
#IfWinActive YouTube
RButton::Send {Left}
MButton::Send {Right}
return

Upvotes: 0

phil294
phil294

Reputation: 10822

Assuming you run on Win10:

I've tried MouseClick commands and simple reassigning keyboard commands to mouse but none of it worked.

AutoHotkey in Windows 10 - Hotkeys not working in some applications Some programs need AutoHotkey to be ran in admin mode, otherwise hotkeys are not recognized.

Upvotes: 0

Related Questions