Jump to content

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

Right mouse button added functionality- Doubleclick it!


  • Please log in to reply
29 replies to this topic
jak
  • Members
  • 159 posts
  • Last active: Dec 16 2010 11:26 PM
  • Joined: 28 Feb 2006
Hi everyone,

I created a simple but I think very functional little script. It allows you to add extra functionality to your RIGHT mouse button.

a) Double click with it to bring up the function of your choice. We all double click with the left button. why not with the right too? I used it to click a link to open it into a new IE window and minimize it.

B) Press and hold. Hold down your right mouse button for 1 sec for yet another function. I use it to open a new compose window in my email.

If you just click it once as usual, you get the right mouse menu as usual.

Here it is (edit as you like): Its part of my autohotkey.ini file.
Rbutton::
;
;it gives you half a second to either complete the double click
;or to complete the press-and-hold cycle. If neither happens
;you get a normal single click response.
;
keywait, rbutton, t0.5
if errorlevel = 1
{
;
;This registers a 'press-n-hold' on the right mouse button.
;ADD YOUR FUNCTIONS HERE, for instance
;you could do a control-n to open a new IE window, as below
;
send, ^n
return
}
else
keywait, rbutton, d, t0.5
if errorlevel = 0
{
;
;this registers a 'double click' on the right mouse button.
;add your functions here, for instance I use it below
;to do a shift-left click which opens a link in its own window
;
send, +{lbutton}
return
}
else 
;
;if neither of the above heppen, send a regular single click
;
mouseclick, right
return
Thats it! Nice functionality that extends the usefulness of the mouse while surfing the web...

;)
Jak

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Thank you for sharing.
PS.: you should use the CODE tags around your script. It will be easier to read, keeping the right indentations.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

AHKPNH
  • Members
  • 37 posts
  • Last active: Jan 30 2014 11:01 PM
  • Joined: 17 Feb 2006
Very Nice, thank you.....

I use it for (copy and paste)
By holding down right button, i copy.
By double clicking right button, i paste.
NICE!!!! :p

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Unfortunately, even with perfect implementation, right press-and-hold interferes with the right-drag function, but as it is, even right-double-click prevents right-dragging, which was very useful, when creating shortcuts, zipping files, etc.

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
modes of operation:
* single-click detected when release occurs in less than 200 ms
* double-click detected when second press occurs in less than 200 ms
* drag detected when press and mouse coordinate differential occurs
* hold detected when press duration exceeds 300 ms
RightButton?double_click@threshold = 200
RightButton?hold@threshold := RightButton?double_click@threshold+100
return

RButton::
    if ( A_TickCount-RightButton?double_click@threshold < RightButton@mark )    ; double-click detected
    {
        SetTimer, timer_RightButton, off

        MsgBox, right-button double-click detected
        return
    }

    RightButton@mark := A_TickCount

    MouseGetPos, m_x1, m_y1
    SetTimer, timer_RightButton, 10
return

timer_RightButton:
    if ( A_TickCount-RightButton@mark >= RightButton?hold@threshold )           ; hold detected
    {
        SetTimer, timer_RightButton, off

        MsgBox, right-button hold detected
    }
    else if ( A_TickCount-RightButton@mark >= RightButton?double_click@threshold
                and !GetKeyState( "RButton", "P" ) )                            ; single-click detected
    {
        SetTimer, timer_RightButton, off

        Send, {RButton}
    }
    else
    {
        MouseGetPos, m_x2, m_y2

        if ( m_x1 "," m_y1 != m_x2 "," m_y2 )                                   ; drag detected
        {
            SetTimer, timer_RightButton, off

            Send, {RButton down}
            
            KeyWait, RButton
            
            Send, {RButton up}
        }
    }
return


kapege.de
  • Members
  • 192 posts
  • Last active: Jan 16 2012 12:34 PM
  • Joined: 07 Feb 2005
I know there's anywhere in the registry the doubleclick time. Does somebody knows where? It could replace the 200 ms. :wink:
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
Try:

DllCall( "GetDoubleClickTime" )


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
It is surprising it isn't in the SysGet list...
(Microsoft is to blame, not Chris! :-))
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

MrB
  • Guests
  • Last active:
  • Joined: --
Doesn't seem to work. Right clicking once frist time after reloading the script, a "right button hold" is detected. Afterwards, even if I click only once, a double click is detected. Same if I hold: a double click is detected.

If I change RightButton?double_click@threshold to 800, it doesnt change the behaviour.

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005

Right clicking once frist time after reloading the script, a "right button hold" is detected. Afterwards, even if I click only once, a double click is detected. Same if I hold: a double click is detected.


I cannot reproduce this behavior.

What version of Windows and AHk are you using?

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
If you only want to use double right-click, it is much simpler. I use the following script to pop up a menu with my personal data I have to enter often into fields on Web forms, but you can use it for anything else. It does not affect right-dragging.
~RButton::

   If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500) {

      Sleep 200   ; wait for right-click menu, fine tune for your PC

      Send {Esc}  ; close it

      MsgBox OK   ; your double-right-click action here

   }

Return


  • Guests
  • Last active:
  • Joined: --
@shimanov
Windows XP SP2, AHK 1.0.42.03, specifically downloaded the latest version to try. No luck though.

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005

@shimanov
Windows XP SP2, AHK 1.0.42.03, specifically downloaded the latest version to try. No luck though.


Since I cannot reproduce the behavior you have described, it may be a system specific issue.

If you would like to continue our investigation, please register and send me a private message. Describe your experiments (in detail), and their outcomes.

selioneru
  • Members
  • 8 posts
  • Last active: Jun 30 2007 04:06 PM
  • Joined: 19 Feb 2006
i had the same problem you had. Did you put the script in the ini file? if so try making the script run separate as a single script i hope it does the trick!

jak
  • Members
  • 159 posts
  • Last active: Dec 16 2010 11:26 PM
  • Joined: 28 Feb 2006
wow, I didnt expect to see much of a response to this little script - Needless to say I'm very happy that some folks found it useful!
I thnk all mice should be shipping with right-click customization options built into the mouse's software!

AHKPNH: copy-paste - NICE!

Regarding LASZLO's note about interference with right-drag function; I never thought of that since I never use right-drag! I'm guessing most people dont use right-drag... But for those that do, SHIMANOV's script is pretty brilliant! I havent tried it but it looks fine to me...