Page 1 of 1

enable/disable a shortcut using another shortcut

Posted: 29 Mar 2019, 13:57
by partof
How can I enable and disable the shortcuts below by pressing both the RButton and the LButton? Any advice will be welcome!

Code: Select all

    SetTitleMatchMode, 2
    WinActivate, YouTube
    RButton::
        Send, {Space}
        return

    SetTitleMatchMode, 2
    WinActivate, YouTube
        WheelUp::
        Send, {Right}
        return

    SetTitleMatchMode, 2
    WinActivate, YouTube
    WheelDown::
        Send, {Left}
        return

Re: enable/disable a shortcut using another shortcut

Posted: 29 Mar 2019, 14:32
by MannyKSoSo
https://autohotkey.com/docs/commands/_If.htm

Example

Code: Select all

toggle := 0

;|This will only go off if toggle is true/1
#If toggle
^b::MsgBox % "I display"

;|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)
^a::toggle := !toggle

Re: enable/disable a shortcut using another shortcut  Topic is solved

Posted: 29 Mar 2019, 20:45
by Hellbent
MannyKSoSo wrote:
29 Mar 2019, 14:32
https://autohotkey.com/docs/commands/_If.htm

Example

Code: Select all

toggle := 0

;|This will only go off if toggle is true/1
#If toggle
^b::MsgBox % "I display"

#If      ;<-------------------------------------------------------------- End Of #If Section


;|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)
^a::toggle := !toggle
You forgot to add the other #if to exit your section.

Re: enable/disable a shortcut using another shortcut

Posted: 30 Mar 2019, 11:28
by partof
Thank you It's working! (Here is my code, I still have a small issue with it, but it's for another question)

Code: Select all

SetTitleMatchMode, Regex

toggle := 0

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

   If (toggle==1){
        #If WinActive("YouTube")
       TrayTip, On, Youtube mode activated,,1
       Hotkey,WheelUp,WheelUp,On
       Hotkey,WheelDown,WheelDown,On

       WheelUp:
     	   IfWinActive, YouTube
           Send, {Right}
           return

       WheelDown:
     	   IfWinActive, YouTube
           Send, {Left}
           return
        ; #If
       }

   If (toggle==0){
       TrayTip, Off, Youtube mode Deactivated,,1
       Hotkey,WheelUp,WheelUpa,On
       Hotkey,WheelDown,WheelDowna,On

       WheelUpa:
           Send, {WheelUp}
           return

       WheelDowna:
           Send, {WheelDown}
           return
       }
}

; because LButton and RButton where remap, they function is lost, so we need to remap them
LButton:: LButton
RButton::RButton

LButton & RButton::
;|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

Re: enable/disable a shortcut using another shortcut

Posted: 01 Apr 2019, 08:00
by MannyKSoSo
Thank you for the fix Hellbent. I don't normally use the #If