LButton/RButton as modifiers + Mouse Wheel/Up/Down

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
XMCQCX
Posts: 229
Joined: 14 Oct 2020, 23:44

LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by XMCQCX » 03 Jul 2022, 08:17

Hi,
I want to use LButton/RButton as modifiers + Mouse Wheel/Up/Down and keep all the functionalities, Drag, Double-Click etc...
-Copy/Paste everywhere with LButton & RButton/RButton & LButton.
-Control the volume everywhere with RButton + Wheel/Up/Down.
-To zoom in Chrome with LButton + Wheel/Up/Down.

The problem with my script is that I lost the ability to drag with RButton. In Chrome, I want to avoid a click after zooming/Unzooming and Copy/Paste everywhere doesn't work at all.

I tried a few things, read some documentation but wasn't able to make it work. How to do this and still keep all the functionalities of RButton, LButton and Mouse Wheel?

Any help would be greatly appreciated!

Code: Select all

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%

;=============================================================================================
; Volume Change with Mouse (Gui)
;=============================================================================================

Gui, GuiVolumeChange: New
Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
Gui, Font, s10 w700
Gui, Add, Text, w300 Center, Volume
Gui, Add, Progress, wp h20 vvol cBlue
Gui, Font, w400
Gui, Add, Text, wp Center vvolText

;=============================================================================================
; Volume Change with Mouse
;=============================================================================================

RButton:: Send, {RButton}
RButton & WheelUp::
RButton & WheelDown::

SoundSet, % Instr(A_ThisHotkey, "WheelDown") ? -2 : "+2"
SoundGet, Volume
GuiControl, GuiVolumeChange:, vol,  % Volume
GuiControl,GuiVolumeChange:, volText, % Round(Volume)
Gui, GuiVolumeChange: Show, % "x" . (A_ScreenWidth/1.275) . "y" . (A_ScreenHeight/1.18) . " NoActivate"
SetTimer, GuiEscape, -1500
Return

GuiEscape:
Gui, GuiVolumeChange: Hide
Return

;=============================================================================================
; Global Hotkeys
;=============================================================================================

; ~LButton & RButton:: ; Copy Selected
; Send, ^c
; Clipwait, 1 
; if (ErrorLevel) {
;     MsgBox, The attempt to copy text onto the clipboard failed.
;     return
; }
; return

; ~RButton & LButton:: ; Paste Selected
; Send, ^v
; Clipwait, 1
; if (ErrorLevel) {
;     MsgBox, The attempt to copy text onto the clipboard failed.
;     return
; }
; return

;=============================================================================================
; Google Chrome
;=============================================================================================

#IfWinActive ahk_exe Chrome.exe

~LButton & WheelUp:: Send, ^{+} ; Zoom In
~LButton & WheelDown:: Send, ^{-}  ; Zoom Out
Last edited by XMCQCX on 03 Jul 2022, 09:30, edited 1 time in total.

User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by mikeyww » 03 Jul 2022, 08:44

One idea (a demonstration):

Code: Select all

#If GetKeyState("LButton", "P")
WheelUp::Send ^{+}
#If

XMCQCX
Posts: 229
Joined: 14 Oct 2020, 23:44

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by XMCQCX » 03 Jul 2022, 12:13

mikeyww wrote:
03 Jul 2022, 08:44
One idea (a demonstration):

Code: Select all

#If GetKeyState("LButton", "P")
WheelUp::Send ^{+}
#If
Thanks a lot for the help. It's always really appreciated. Sadly, I didn't make any progress. How to release the LButton/RButton without "completing the click". When I release the LButton it's clicking, when I release the RButton a context menu can appears.

User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by mikeyww » 03 Jul 2022, 13:22

You would have to decide what you want to happen. First, you press LButton, for whatever reason. What happens next? What happens after that? You would need to describe all possibilities, step by step.

XMCQCX
Posts: 229
Joined: 14 Oct 2020, 23:44

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by XMCQCX » 03 Jul 2022, 13:49

Another example, with this script to adjust the volume everywhere with RButton + Wheel/Up/Down. The context menu is opening after changing the volume. How to prevent the menu from opening if RButton + Wheel/ Up or Down was press to change the volume.

Code: Select all

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%

;=============================================================================================
; Volume Change with Mouse (Gui)
;=============================================================================================

Gui, GuiVolumeChange: New
Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
Gui, Font, s10 w700
Gui, Add, Text, w300 Center, Volume
Gui, Add, Progress, wp h20 vvol cBlue
Gui, Font, w400
Gui, Add, Text, wp Center vvolText

;=============================================================================================
; Volume Change with Mouse
;=============================================================================================

~RButton & WheelUp::
~RButton & WheelDown::
;Or
;#If GetKeyState("RButton", "P")
;WheelUp::
;WheelDown::

SoundSet, % Instr(A_ThisHotkey, "WheelDown") ? -2 : "+2"
SoundGet, Volume
GuiControl, GuiVolumeChange:, vol,  % Volume
GuiControl,GuiVolumeChange:, volText, % Round(Volume)
Gui, GuiVolumeChange: Show, % "x" . (A_ScreenWidth/1.275) . "y" . (A_ScreenHeight/1.18) . " NoActivate"
SetTimer, GuiEscape, -1500
Return

GuiEscape:
Gui, GuiVolumeChange: Hide
Return

User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by mikeyww » 03 Jul 2022, 14:10

You demonstrated my point.

XMCQCX
Posts: 229
Joined: 14 Oct 2020, 23:44

Re: LButton/RButton as modifiers + Mouse Wheel/Up/Down

Post by XMCQCX » 04 Jul 2022, 04:30

mikeyww wrote:
03 Jul 2022, 14:10
You demonstrated my point.
Thanks mikeyww. I definitely need to learn more about Remapping Keys. I will read more documentations and find more examples. Have a nice day !

Post Reply

Return to “Ask for Help (v1)”