enable/disable a shortcut using another shortcut Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

enable/disable a shortcut using another shortcut

29 Mar 2019, 13:57

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
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: enable/disable a shortcut using another shortcut

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"

;|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
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

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

29 Mar 2019, 20:45

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.
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Re: enable/disable a shortcut using another shortcut

30 Mar 2019, 11:28

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
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: enable/disable a shortcut using another shortcut

01 Apr 2019, 08:00

Thank you for the fix Hellbent. I don't normally use the #If

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 118 guests