Is there a way to write an AHK script that automatically copies whatever text I select with my mouse, from either of these 2 programs, into my clipboard?
I want to be able to mark and copy with the left button only, and to paste with the middle button - same as linux does...
I found this script from superuser whioch doesn't work in AHK v2 - which if I can get around the "sendinput ^c" problem, looks like most of the work I need to do here
Code: Select all
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