Ahk vs. win7 default binds

Get help with using AutoHotkey and its commands and hotkeys
nalbe
Posts: 2
Joined: 28 Oct 2015, 01:38

Ahk vs. win7 default binds

28 Oct 2015, 02:46

Hi. I decided to control system volume using mouse right button + scroll up/down. Something like this:

Code: Select all

$RButton::Send {RButton}
 RButton & WheelUp::Send, {Volume_Up 1}
 RButton & WheelDown::Send, {Volume_Down 1}
In this case, drag&drop with right button in windows isn't work. It opens menu when rbutton released, but no drag&drop. How i can fix it?
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Ahk vs. win7 default binds

28 Oct 2015, 03:29

It works this way so that you can activate one of the combination hotkeys without activating RButton's normal function (a context menu).

You can use tilde (~) to avoid interfering with a key/button's native function:

Code: Select all

~RButton & WheelUp::Send, {Volume_Up 1}
~RButton & WheelDown::Send, {Volume_Down 1}
However, that will show a context menu even if you adjust the volume. To avoid this, you can send {Esc} if you did not activate another hotkey:

Code: Select all

~RButton & WheelUp::Send, {Volume_Up 1}
~RButton & WheelDown::Send, {Volume_Down 1}
~RButton::return
~RButton up::
    if (A_PriorHotkey != "~RButton")
        Send {Esc}
    return
Be aware that the Esc keypress could have terrible consequences ;) if you right-click somewhere that doesn't pop up a menu. It isn't possible to reliably detect non-standard context menus (such as those used by most web browsers). It is possible to reliably detect standard menus (window title ahk_class #32768), but waiting for it to appear means that it's more likely you'll see the menu before it gets cancelled.

Make sure you have at least AutoHotkey v1.1.14.02. Custom combinations with tilde (~) behave differently in earlier versions.

To get any better results, you would need more complexity. For instance, it would be possible to block the right-click and send an artificial right-click only when the mouse starts to move. You can block the right-click by removing ~ from the RButton and RButton up hotkeys, and send it using the Click or Send commands. To get the best results (detecting attempted movement before the cursor visibly moves), you could use a mouse hook, but that is NOT trivial.

Note: $ is completely ineffective for mouse hotkeys. For keyboard hotkeys, it means "use the keyboard hook", but it is often redundant (as with x:: if you also have x & y::).
nalbe
Posts: 2
Joined: 28 Oct 2015, 01:38

Re: Ahk vs. win7 default binds

28 Oct 2015, 06:28

Thanks for explanation! I will play with it.

Return to “Ask For Help”

Who is online

Users browsing this forum: effel and 148 guests