AutoHotkey Community

It is currently May 27th, 2012, 8:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 28th, 2006, 9:02 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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...

;)
Jak


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2006, 11:32 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Thank you for sharing.
PS.: you should use the CODE tags around your script. It will be easier to read, keeping the right indentations.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2006, 10:26 pm 
Offline

Joined: February 17th, 2006, 2:29 pm
Posts: 37
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 1:41 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 7:15 am 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 10:22 am 
Offline

Joined: February 7th, 2005, 11:11 am
Posts: 192
Location: Munich, Germany
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 10:45 am 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
Try:

Code:
DllCall( "GetDoubleClickTime" )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 11:32 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
It is surprising it isn't in the SysGet list...
(Microsoft is to blame, not Chris! :-))

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 11:36 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 4:45 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2006, 8:18 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2006, 5:49 pm 
@shimanov
Windows XP SP2, AHK 1.0.42.03, specifically downloaded the latest version to try. No luck though.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2006, 10:12 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Dear MrB
PostPosted: March 10th, 2006, 1:08 am 
Offline

Joined: February 19th, 2006, 7:31 am
Posts: 8
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject: wow
PostPosted: March 17th, 2006, 11:47 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Aravind, Google Feedfetcher, Stigg and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group