Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Issue with RButton


  • Please log in to reply
11 replies to this topic
abhijith444
  • Members
  • 21 posts
  • Last active: Apr 28 2012 02:43 PM
  • Joined: 28 Apr 2012
This code disables my Right Click
What am I doing wrong?
Autohotkey 1.0.48.05

RButton & MButton::Send {Volume_Mute}
RButton & WheelUp::Send {Volume_Up}
RButton & WheelDown::Send {Volume_Down}


dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010
The tilde "~" symbol allows a key to function normally even if it is a hotkey:
~RButton & MButton::Send {Volume_Mute}

~RButton & WheelUp::Send {Volume_Up}

~RButton & WheelDown::Send {Volume_Down}
Now, a problem with this is now every time you use one of these hotkeys you will have a context menu popping up.
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

abhijith444
  • Members
  • 21 posts
  • Last active: Apr 28 2012 02:43 PM
  • Joined: 28 Apr 2012

The tilde "~" symbol allows a key to function normally even if it is a hotkey:

~RButton & MButton::Send {Volume_Mute}
~RButton & WheelUp::Send {Volume_Up}
~RButton & WheelDown::Send {Volume_Down}

Thanks a lot..

Now, a problem with this is now every time you use one of these hotkeys you will have a context menu popping up.

I can live with that :?

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
Piece of cake :
$RButton::
	Send {RButton}
Return

RButton & MButton::Send {Volume_Mute}
RButton & WheelUp::Send {Volume_Up}
RButton & WheelDown::Send {Volume_Down}


dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010
Excellent CodeKiller! :D
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

abhijith444
  • Members
  • 21 posts
  • Last active: Apr 28 2012 02:43 PM
  • Joined: 28 Apr 2012

Piece of cake :

$RButton::
	Send {RButton}
Return

RButton & MButton::Send {Volume_Mute}
RButton & WheelUp::Send {Volume_Up}
RButton & WheelDown::Send {Volume_Down}


Just Awesome!!!!!

jameless
  • Members
  • 3 posts
  • Last active: Jun 20 2012 12:44 PM
  • Joined: 20 Jun 2012
The only issue I am now having with this script is that I can't right click and drag. Anyone know of a solution for that?


EDIT: Sorry for the double post but I just registered and preferred to have this follow me. Can someone please delete my previous comment?
[Moderator's note: It is done.]

vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011
Why not something like this
#If MouseIsOver("ahk_class Shell_TrayWnd")
~LButton & WheelUp::
Send {Volume_Up}
Return
~LButton & WheelDown::
Send {Volume_Down}
Return
~LButton & MButton::
Send {Volume_Mute}
Return

MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}

With this if the mouse is over the taskbar and if you press and hold the left button,you can use the wheel to increase\decrease the volume and the middle click to mute it.

jameless
  • Members
  • 3 posts
  • Last active: Jun 20 2012 12:44 PM
  • Joined: 20 Jun 2012
I appreciate the option there, but I feel the Right mouse button is a little easier to grab a hold of. I did go back to choosing the ~ option for the right mouse button and am just living with the context menu for the time being. Unless someone can figure out a way to still allow the Right click + drag with @CodeKiller's option.

vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011
This way then
#If MouseIsOver("ahk_class Shell_TrayWnd")
$RButton::
   Send {RButton}
Return

RButton & WheelUp::
Send {Volume_Up}
Return
RButton & WheelDown::
Send {Volume_Down}
Return
RButton & MButton::
Send {Volume_Mute}
Return

MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}

Again,only work while you right click on the taskbar and use the wheel and middle button.You will be able to use the right click menu and drag with the right button.
The only thing that you have to deal with,is that it works only when the right button is used on the taskbar.You can't change the volume if your are not holding the right button while the mouse of over the taskbar

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
[color=green]; Concept: Implement RButton as a modifier for other hotkeys[/color]

[color=green];          by monitoring the mouse position and button state.[/color]



[color=green]; Requires:

;   - AutoHotkey (any version should be fine)

;   - A mouse with a wheel

;   - Two or more fingers (optional but recommended)[/color]



[color=green]; Start with wheel/MButton hotkeys disabled:[/color]

gosub DisableRButtonHotkeys



RButton::

    [color=green]; Enable hotkeys while RButton is down.[/color]

    Hotkey WheelUp,   On

    Hotkey WheelDown, On

    Hotkey MButton,   On

    [color=green]; Determine initial mouse position.[/color]

    CoordMode Mouse, Screen

    MouseGetPos x1, y1

    Loop

    {

        [color=green]; If another hotkey has been triggered...[/color]

        if (A_ThisHotkey != "RButton")

        {

            [color=green]; Stop monitoring the other conditions (below).  Just wait[/color]

            [color=green]; for the button to be released, then disable the hotkeys.[/color]

            KeyWait RButton

            break

        }

        [color=green]; If button has been released...[/color]

        if !GetKeyState("RButton", "P")

        {

            [color=green]; Press and release the button.[/color]

            MouseClick R

            [color=green]; Break out of the loop to disable the hotkeys.[/color]

            break

        }

        MouseGetPos x2, y2

        [color=green]; If mouse has moved...[/color]

        if (x1 != x2 || y1 != y2)

        {

            [color=green]; Set speed to "instant" for best results.[/color]

            SetDefaultMouseSpeed 0

            [color=green]; Press the button down (at the initial mouse position).[/color]

            Click Right Down %x1%, %y1%

            [color=green]; Move back to where the user had moved the mouse.[/color]

            MouseMove x2, y2

            [color=green]; Wait for the button to be released.[/color]

            KeyWait RButton

            [color=green]; Release the button.[/color]

            Click Right Up

            [color=green]; Break out of the loop to disable the hotkeys.[/color]

            break

        }

        [color=green]; Yield CPU time to other applications.[/color]

        Sleep 1

    }

    [color=green]; Disable the hotkeys.[/color]

    DisableRButtonHotkeys:

    Hotkey WheelUp,   Off

    Hotkey WheelDown, Off

    Hotkey MButton,   Off

return



WheelUp::   Send {Volume_Up}

WheelDown:: Send {Volume_Down}

MButton::   Send {Volume_Mute}



jameless
  • Members
  • 3 posts
  • Last active: Jun 20 2012 12:44 PM
  • Joined: 20 Jun 2012
@vsub:I got an error with that script in regards to the #If MouseIsOver("ahk_class Shell_TrayWnd") line.

Honestly if I have to right click on the taskbar, I can just click on the speaker icon and scroll it. So I very much appreciate your effort and time. But I would still prefer to have the context menu vs. having to mouse over the taskbar to accomplish the volume control.

EDIT: Lexikos posted same time I clicked to post.

@Lexikos: This script works perfectly for me. Thanks very much.