AutoHotkey Community

It is currently May 26th, 2012, 5:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: July 9th, 2004, 3:58 am 
Offline

Joined: July 9th, 2004, 3:52 am
Posts: 3
This script automatically copies any mouse selection made with the left mouse button, and makes the middle mouse button function as a 'paste' command. Instead of sending a copy command every time the left button is pressed, it checks to see if there was a significant change in the position of the mouse cursor between the button push and the button release (signifying that the mouse was used to make a selection). Leave a comment if you like it... or hate it.
--Barky

Code:
~LButton:: ; Make the left mouse button a hotkey, but allow it to function as normal.
MouseGetPos, xA, yA
loop ; Begin a loop.
{
   Sleep, 10 ; Wait 10 milliseconds.
   GetKeyState, LButton_state, LButton, P ; Check on the status of the left mouse button.
   if LButton_state = U ; If the left mouse button has been released.
   {   
      MouseGetPos, xB, yB
      Transform, xA, abs, %xA% ; Return the absolute value of xA.
      Transform, xB, abs, %xB%
      Transform, yA, abs, %yA%
      Transform, yB, abs, %yB%
      xDiff = 0
      xDiff += %xA%   ; Add xA to xDiff.
      xDiff -= %xB%   ; Subtract xA from xDiff.
      Transform, xDiff, abs, %xDiff%
      yDiff = 0
      yDiff += %yA%
      yDiff -= %yB%
      Transform, yDiff, abs, %yDiff%
      diffSum = 0
      diffSum += %xDiff%
      diffSum += %yDiff%
      If diffSum > 10
      {
         Send, ^c ; Copy.
         clipboard = %clipboard%   ; Convert the cliboard contents to plain text.
      }
      break
   }
}
return

MButton:: ; Make the middle mouse button a hotkey, and _don't_ allow it to function as normal.
send, ^v ; Paste
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 5:36 am 
Offline

Joined: June 19th, 2004, 9:02 pm
Posts: 68
i like the feature when i'm using mIRC

nice to know i can use it in any program now

when finding the difference between the before and after mouse positions you could make the vertical require less difference than the horizontal

or you could use the pythagorean theorem to find the hypoteneuse

or both

_________________
AHK = Hella fun


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2004, 4:32 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
Wow, I bet this would make linux junkies who have to use windows happy. I'll have to show this to my professor when I go back to school.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks!
PostPosted: October 25th, 2011, 11:21 pm 
It work's good :), but I change MButton to ~MButton.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 13 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