YouTube Playback Speed - Mouse Wheel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
keyleoxauto
Posts: 7
Joined: 23 Feb 2017, 19:14

YouTube Playback Speed - Mouse Wheel

23 Feb 2017, 19:31

Hi everyone, english is not my first language so forgive any mistakes.

I use Opera and to to control the playback speed of youtube videos I have an extension that allows me to do so, by pressing NumpadAdd and NumpadSub, but I want to do the same by just moving my mouse wheel WHEN MY MOUSE POINTER IS OVER A YOUTUBE VIDEO (is that even possible for AutoHotKey?), because I still want to scroll up and down the page to for example read the comments, you get me right?

This is the script I have, and even though it's not want I want, it still doesn't work:

SetTitleMatchMode 2
#IfWinActive YouTube
WheelDown::NumpadSub
WheelUp::NumpadAdd
Last edited by keyleoxauto on 23 Feb 2017, 19:37, edited 1 time in total.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: YouTube Playback Speed - Mouse Wheel

23 Feb 2017, 19:36

You'd need a way to know if your mouse is overtop the video itself or not. AHK and Opera probably don't have the best way to do that. If you're lucky, Opera creates a Control that Window Spy can see. Window Spy is included in your download of AHK - right click on any running script's tray icon (by the system clock) and select Window Spy.

I don't think AHK will be a solution for you to get exactly what you want. Instead, you'd probably need to write an extension yourself to activate those in-page hotkeys like that extension is doing but with a detection for if you are moused over the video. Javascript alone might be what you want, detecting WebPage Elements on MouseOver and creating hotkeys dynamically. No idea how to do that.

Alternatively, you can try using hotkeys to toggle on and off that action though, like pressing the MButton:

Code: Select all

#If ; no context-sensitivity
MButton::toggle:=!toggle

#If toggle ; or #If (toggle) && WinActive("YouTube") with a prior set SetTitleMatchMode, 2
WheelDown::NumpadSub
WheelUp::NumpadAdd
keyleoxauto
Posts: 7
Joined: 23 Feb 2017, 19:14

Re: YouTube Playback Speed - Mouse Wheel

23 Feb 2017, 19:42

Exaskryz wrote:You'd need a way to know if your mouse is overtop the video itself or not. AHK and Opera probably don't have the best way to do that. If you're lucky, Opera creates a Control that Window Spy can see. Window Spy is included in your download of AHK - right click on any running script's tray icon (by the system clock) and select Window Spy.

I don't think AHK will be a solution for you to get exactly what you want. Instead, you'd probably need to write an extension yourself to activate those in-page hotkeys like that extension is doing but with a detection for if you are moused over the video. Javascript alone might be what you want, detecting WebPage Elements on MouseOver and creating hotkeys dynamically. No idea how to do that.

Alternatively, you can try using hotkeys to toggle on and off that action though, like pressing the MButton:

Code: Select all

#If ; no context-sensitivity
MButton::toggle:=!toggle

#If toggle ; or #If (toggle) && WinActive("YouTube") with a prior set SetTitleMatchMode, 2
WheelDown::NumpadSub
WheelUp::NumpadAdd
Hey that last thing works man! Sorry I call it "thing" but I know very little about AHK and scripts.
It's not exactly what I wanted (I have an extra step to do with MButton) but it works, so for now I'll take it. Thanks!
4GForce
Posts: 553
Joined: 25 Jan 2017, 03:18
Contact:

Re: YouTube Playback Speed - Mouse Wheel

23 Feb 2017, 19:59

keyleoxauto wrote: Hey that last thing works man! Sorry I call it "thing" but I know very little about AHK and scripts.
It's not exactly what I wanted (I have an extra step to do with MButton) but it works, so for now I'll take it. Thanks!
Wouldn't something like this work ?? ( UNTESTED )

Code: Select all

WheelDown::
	WinGetActiveTitle title
	if(InStr(title, "Youtube - Google Chrome")) {
		send (NumpadSub)
	}
Return
Edit: you might wanna replace google chrome by opera something whatever the window title is
keyleoxauto
Posts: 7
Joined: 23 Feb 2017, 19:14

Re: YouTube Playback Speed - Mouse Wheel

23 Feb 2017, 20:07

4GForce wrote:
keyleoxauto wrote: Hey that last thing works man! Sorry I call it "thing" but I know very little about AHK and scripts.
It's not exactly what I wanted (I have an extra step to do with MButton) but it works, so for now I'll take it. Thanks!
Wouldn't something like this work ?? ( UNTESTED )

Code: Select all

WheelDown::
	WinGetActiveTitle title
	if(InStr(title, "Youtube - Google Chrome")) {
		send (NumpadSub)
	}
Return
Edit: you might wanna replace google chrome by opera something whatever the window title is

Thanks 4GForce I tried but it doesn't work. I even change the title to YouTube - Opera and then to only Youtube.

Exaskryz wrote:You'd need a way to know if your mouse is overtop the video itself or not. AHK and Opera probably don't have the best way to do that. If you're lucky, Opera creates a Control that Window Spy can see. Window Spy is included in your download of AHK - right click on any running script's tray icon (by the system clock) and select Window Spy.

I don't think AHK will be a solution for you to get exactly what you want. Instead, you'd probably need to write an extension yourself to activate those in-page hotkeys like that extension is doing but with a detection for if you are moused over the video. Javascript alone might be what you want, detecting WebPage Elements on MouseOver and creating hotkeys dynamically. No idea how to do that.

Alternatively, you can try using hotkeys to toggle on and off that action though, like pressing the MButton:

Code: Select all

#If ; no context-sensitivity
MButton::toggle:=!toggle

#If toggle ; or #If (toggle) && WinActive("YouTube") with a prior set SetTitleMatchMode, 2
WheelDown::NumpadSub
WheelUp::NumpadAdd
Exaskryz I now have a problem, as long as I have a YouTube tab open, I can´t use MButton in other tabs to open links in new tabs for example, or close tabs (that's too many tabs haha) so I was wondering, is there a way to edit the script so the MButton toggle thing only works on a YouTube active tab?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: YouTube Playback Speed - Mouse Wheel

24 Feb 2017, 05:32

I had a comment that alludes to that. What you may want then is to use this code:

Code: Select all

SetTitleMatchMode, 2
#IfWinActive YouTube
MButton::toggle:=!toggle

#If (toggle) && WinActive("YouTube")
WheelDown::NumpadSub
WheelUp::NumpadAdd

#If ; resets context-sensitivity for any other hotkeys you may have
keyleoxauto
Posts: 7
Joined: 23 Feb 2017, 19:14

Re: YouTube Playback Speed - Mouse Wheel

27 Feb 2017, 18:38

Exaskryz wrote:I had a comment that alludes to that. What you may want then is to use this code:

Code: Select all

SetTitleMatchMode, 2
#IfWinActive YouTube
MButton::toggle:=!toggle

#If (toggle) && WinActive("YouTube")
WheelDown::NumpadSub
WheelUp::NumpadAdd

#If ; resets context-sensitivity for any other hotkeys you may have

It doesn't work at all now.

I think that this: "SetTitleMatchMode, 2 #IfWinActive YouTube" is not working

What about pressing RButton while moving the mouse wheel up (NumpadAdd) and down (NumpadSub)?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: YouTube Playback Speed - Mouse Wheel

27 Feb 2017, 18:53

Did you make sure your SetTitleMatchMode, 2 was in the auto-execute section?

As for your alternative idea, you could try this:

Code: Select all

#If GetKeyState("RButton","P") ; if RButton is physically held
WheelDown::NumpadSub
WheelUp::NumpadAdd

#If ; reset context-sensitivity
Or just do a combination hotkey, and depending on your use case, with the ~ modifier.

Code: Select all

~RButton & WheelUp::Send {NumpadAdd}
~RButton & WheelDown::Send {NumpadSub}
Haswell
Posts: 90
Joined: 21 Feb 2016, 17:11

Re: YouTube Playback Speed - Mouse Wheel

01 Mar 2017, 03:53

It might be more easy to use GreaseMonkey/Tampermonkey for this.
Focusing our efforts on non-productive and non-creative endeavours wastes lives as surely as war.
Jacque Fresco / The best that money can't buy

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 286 guests