(using only the mouse to go forward/backward on youtube) + (enable/disable all youtube hotkeys with a single hotkey)

Post your working scripts, libraries and tools for AHK v1.1 and older
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

(using only the mouse to go forward/backward on youtube) + (enable/disable all youtube hotkeys with a single hotkey)

Post by partof » 31 Mar 2019, 14:26

When you right click + left click this code activates/deactivates some custom hotkeys for youtube (eg: jump forward, backward...). It works only when the active window is youtube (so it won't bother you elsewhere).

Code: Select all

; ********************************* (using only the mouse to go forward/backward on youtube) + (enable/disable all youtube hotkeys with a single hotkey)

SetTitleMatchMode, Regex
toggle := 0

youtubesetting(toggle){   
  ;|This will only go off if toggle is true/1

; it will be activated only on youtube (but dactivativated anywhere)
   #If WinActive("YouTube") ; pb: i=you can't desactivated it unless you are on YouTube...

   If (toggle==1){
       TrayTip, ON, Youtube mode activated,,1
       Hotkey,WheelUp,WheelUpfunction,On
       Hotkey,WheelDown,WheelDownf,On

       WheelUpfunction:
           Send, {Right}
           return

       WheelDownf:
           Send, {Left}
           return
       }


   If (toggle==0){
       TrayTip, OFF, Youtube mode disactivated,,1

; if toogle is OFF: set the button to their original  use
       Hotkey,WheelUp,WheelUpfunctionBack,On
       Hotkey,WheelDown,WheelDownfunctionBack,On

       WheelUpfunctionBack:
           Send, {WheelUp}
           return

       WheelDownfunctionBack:
           Send, {WheelDown}
           return
       }
}


~LButton & RButton::
; tilde: that hotkey will fire when the key is pressed instead of being delayed until the key is released
;|This will change the toggle var to the inverse of what it's original value is (0 = 1 and 1 = 0 || true = false and false = true)
toggle := !toggle
youtubesetting(toggle)
return


#if

Return to “Scripts and Functions (v1)”