I have spend the last few days tumbling around with ahk basics trying to make working mouse volume control.
As google have come to help I found numerous threads in the forum with many options making my hands itchy to try many other things.
I even made my joystick do things as well volume control but I still wanted to do that particular thing with my mouse. So I continued searching and I found awesome solution in the post from Lexikos in this thread https://autohotkey.com/board/topic/8011 ... h-rbutton/ .
It works wonderful but soon I had cramps because I have big fingers and I have to cram my fingers while holding the right button and scrolling in the same time.
So I tried to modify it with replacing rbutton with xbutton2 but I failed. Well, actually worked but having similar problem the way rbutton had in the simpler codes in the beginning of the thread. I can`t write in that thread because it`s archived.
So my question is how to modify Lexikos code which is the one bellow replacing RButton with xbutton2 and still maintain the functions.
Code: Select all
; Concept: Implement RButton as a modifier for other hotkeys
; by monitoring the mouse position and button state.
; Requires:
; - AutoHotkey (any version should be fine)
; - A mouse with a wheel
; - Two or more fingers (optional but recommended)
; Start with wheel/MButton hotkeys disabled:
gosub DisableRButtonHotkeys
RButton::
; Enable hotkeys while RButton is down.
Hotkey WheelUp, On
Hotkey WheelDown, On
Hotkey MButton, On
; Determine initial mouse position.
CoordMode Mouse, Screen
MouseGetPos x1, y1
Loop
{
; If another hotkey has been triggered...
if (A_ThisHotkey != "RButton")
{
; Stop monitoring the other conditions (below). Just wait
; for the button to be released, then disable the hotkeys.
KeyWait RButton
break
}
; If button has been released...
if !GetKeyState("RButton", "P")
{
; Press and release the button.
MouseClick R
; Break out of the loop to disable the hotkeys.
break
}
MouseGetPos x2, y2
; If mouse has moved...
if (x1 != x2 || y1 != y2)
{
; Set speed to "instant" for best results.
SetDefaultMouseSpeed 0
; Press the button down (at the initial mouse position).
Click Right Down %x1%, %y1%
; Move back to where the user had moved the mouse.
MouseMove x2, y2
; Wait for the button to be released.
KeyWait RButton
; Release the button.
Click Right Up
; Break out of the loop to disable the hotkeys.
break
}
; Yield CPU time to other applications.
Sleep 1
}
; Disable the hotkeys.
DisableRButtonHotkeys:
Hotkey WheelUp, Off
Hotkey WheelDown, Off
Hotkey MButton, Off
return
WheelUp:: Send {Volume_Up}
WheelDown:: Send {Volume_Down}
MButton:: Send {Volume_Mute}