Page 1 of 1

Can't highlight text using LButton even if it has been remaped to it's original states (after using it as hotkey)

Posted: 30 Mar 2019, 11:41
by partof
I have a bug in this script that I can't fix.

I want the remap of WheelDowWheelUp to left/right to work only on a youtube page but I would like to be able to enable/disable this remaping with the double click on LButton & RButton anywhere (on any active page, not just on youtube).

(The toggle : = 0 activate/deactivate the youtube shortcuts when I press the LButton & RButton mouse buttons).

The problem is that this code prevents me to highlight text (by pressing LButton, holding it, drag it over some text and releasing LButton) ― even if I remapped back the hotkey at the end (LButton:: LButton).

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 were remapped, we need to remap them to their original usage.
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: Can't highlight text using LButton even if it has been remaped to it's original states (after using it as hotkey)  Topic is solved

Posted: 30 Mar 2019, 15:38
by Osprey
Try this:

Code: Select all

~LButton & RButton
Also, remove the LButton:: and RButton:: hotkeys.

Re: Can't highlight text using LButton even if it has been remaped to it's original states (after using it as hotkey)

Posted: 31 Mar 2019, 14:15
by partof
That was it, thank you so much!

The explanation:
When we use the tilde as prefix the hotkey will fire when the key is pressed instead of being delayed until the key is released source: (https://autohotkey.com/docs/Hotkeys.htm)
~LButton & RButton::