61

Is there any application to mimic the "Select to Copy and Middle Click to Paste" behaviour in Windows? I was hoping to find an AutoHotkey script for this, but I couldn't.

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400
swamplord
  • 1,088

6 Answers6

30

If you're looking for an AutoHotkey script, this one should probably do!

Here's an implementation for copy on select. You can simply select some text and it is copied immediately without having to press ctrl+c.

Conveinent middle button paste is also provided, but with a twist. Middlebutton is useful in browsers, so there is a short time (configurable) while you can paste with the middle button after copy, before original middleclick functionality is restored.

Also, if you click with the right button it cancels middlebutton paste.

Since after selection you usually click with the left button to the place where you want to paste, so that you put the focus there, it is done automatically when using middlebutton pasting.

clipx integration is also added to Ctrl+middlebutton.

I've been using the script for a few days and it's quite convenient. Sometimes the copy tooltip appears unwantedly when something is dragged, but it doesn't cause any problems.

Snark
  • 33,097
24

Well, there's the True X-Mouse Gizmo, if that works in your Windows version (it's a bit dated).

TataBlack
  • 999
13

Check out AutoClipX.

AutoClipX is a highly configurable program that automatically copies selected objects to the Windows clipboard like text, files and folders. Quickly paste what you have copied by clicking a mouse button! AutoClipX runs quietly in the system tray while you work as usual.

sangorys
  • 103
valentt
  • 332
  • 3
  • 12
3

Shallow copy on selection and shallow paste on middle click in Windows 11 (AutoHotkey script):

cos_mousedrag_treshold := 20 ; pixels
cos_copied_text := ""

#IfWinNotActive ahk_class ConsoleWindowClass

~lButton:: MouseGetPos, cos_mousedrag_x, cos_mousedrag_y keywait lbutton mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2 if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold) { wingetclass cos_class, A if (cos_class == "Emacs") sendinput !w else { previous_clipboard := clipboard sendinput ^c sleep 50 ; wait for copied text to be stored in clipboard cos_copied_text := clipboard clipboard := previous_clipboard } } return

~mbutton:: WinGetClass cos_class, A if (cos_class == "Emacs") SendInput ^y else { previous_clipboard := clipboard clipboard := cos_copied_text ; copy stored text to clipboard SendInput ^v sleep 50 ; I'm not sure if this is necessary clipboard := previous_clipboard } return

#IfWinNotActive

;; clipx ^mbutton:: sendinput ^+{insert} return

This is a modified version of @Snark's answer, which in turn is taken from an anonymous post.

To use this AutoHotkey script, you need to have AutoHotkey installed on your computer. Once you've installed AutoHotkey, save this script as a .ahk file and then double-click the file to run it. The script will run in the background, you can see its icon on the right side of the taskbar.

Ctrl-C
  • 141
0

Solved this by using AutoHotkey v2 (working flawlessly, system-wide) (copy, paste and middle mouse button) -> https://github.com/capitanbarbosa/linux_middle_click_for_windows

#Requires AutoHotkey v2.0

MButton:: { ; Check if the cursor is over an edit control or other text input if (A_Cursor = "IBeam") { prevClipboard := A_Clipboard A_Clipboard := ""

    ; Try to copy any selected text
    Send("^c")
    ClipWait(0.5)

    if (A_Clipboard != "")
    {
        ; Text was selected and copied, keep it in clipboard
        return
    }

    ; If no text was copied and no text is selected, paste the previous clipboard content
    if (A_Clipboard == "")
    {
        A_Clipboard := prevClipboard
        Send("^v")
        return
    }

    ; If no text was copied, try to select all text and copy
    Send("^a^c")
    ClipWait(0.5)

    if (A_Clipboard != "")
    {
        ; Text was copied after selecting all, keep it in clipboard
        Send("{Right}")  ; Move cursor to end of text
        return
    }

    ; If still no text, paste the previous clipboard content
    A_Clipboard := prevClipboard
    Send("^v")
}
else
{
    ; Not over a text input, send normal middle click
    Send("{MButton}")
}

}

-3
SetWinDelay,2
CoordMode,Mouse
return

~MButton::
sleep 100
    Send, ^v
return
~LButton:: 

MouseGetPos x0, y0
   Loop
   {
     Sleep 20
     GetKeyState keystate, LButton
     IfEqual keystate, U, {
       MouseGetPos x, y
       break
     }
   }
   if (x-x0 > 5 or x-x0 < -5 or y-y0 > 5 or y-y0 < -5)
   {                             
      Send ^c
   }


 if (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < DllCall("GetDoubleClickTime"))            
      Send ^c

 if (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < DllCall("GetDoubleClickTime"))
 doubleclick := true

return

#If doubleclick
  ~LButton::
  doubleclick := false
  if (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < DllCall("GetDoubleClickTime"))
  {
      Send, ^c
  }
  return