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 

Cut and paste with the mouse.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Barky



Joined: 09 Jul 2004
Posts: 3

PostPosted: Fri Jul 09, 2004 3:58 am    Post subject: Cut and paste with the mouse. Reply with quote

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



Joined: 19 Jun 2004
Posts: 68

PostPosted: Fri Jul 09, 2004 5:36 am    Post subject: Reply with quote

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



Joined: 02 Jul 2004
Posts: 206

PostPosted: Sat Jul 24, 2004 4:32 pm    Post subject: Reply with quote

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

 
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