AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Right mouse button added functionality- Doubleclick it!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
jak



Joined: 28 Feb 2006
Posts: 93

PostPosted: Tue Feb 28, 2006 9:02 am    Post subject: Right mouse button added functionality- Doubleclick it! Reply with quote

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.
Code:
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...

Wink
Jak
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Feb 28, 2006 11:32 am    Post subject: Reply with quote

Thank you for sharing.
PS.: you should use the CODE tags around your script. It will be easier to read, keeping the right indentations.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Wed Mar 01, 2006 10:26 pm    Post subject: Reply with quote

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!!!! Razz
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Mar 02, 2006 1:41 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 612

PostPosted: Thu Mar 02, 2006 7:15 am    Post subject: Reply with quote

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


Code:
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
Back to top
View user's profile Send private message
kapege.de



Joined: 07 Feb 2005
Posts: 186
Location: Munich, Germany

PostPosted: Thu Mar 02, 2006 10:22 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message Visit poster's website
shimanov



Joined: 25 Sep 2005
Posts: 612

PostPosted: Thu Mar 02, 2006 10:45 am    Post subject: Reply with quote

Try:

Code:
DllCall( "GetDoubleClickTime" )
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Mar 02, 2006 11:32 am    Post subject: Reply with quote

It is surprising it isn't in the SysGet list...
(Microsoft is to blame, not Chris! Smile)
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
MrB
Guest





PostPosted: Thu Mar 02, 2006 11:36 am    Post subject: Reply with quote

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.
Back to top
shimanov



Joined: 25 Sep 2005
Posts: 612

PostPosted: Thu Mar 02, 2006 4:45 pm    Post subject: Reply with quote

MrB wrote:
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?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Mar 02, 2006 8:18 pm    Post subject: Reply with quote

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.
Code:
~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
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Mar 03, 2006 5:49 pm    Post subject: Reply with quote

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



Joined: 25 Sep 2005
Posts: 612

PostPosted: Fri Mar 03, 2006 10:12 pm    Post subject: Reply with quote

Anonymous wrote:
@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.
Back to top
View user's profile Send private message
selioneru



Joined: 19 Feb 2006
Posts: 8

PostPosted: Fri Mar 10, 2006 1:08 am    Post subject: Dear MrB Reply with quote

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!
Back to top
View user's profile Send private message
jak



Joined: 28 Feb 2006
Posts: 93

PostPosted: Fri Mar 17, 2006 11:47 pm    Post subject: wow Reply with quote

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...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group