Skip to content

Instantly share code, notes, and snippets.

@dpriskorn
Last active April 20, 2021 06:22
Show Gist options
  • Save dpriskorn/424bf4dc984176c7353a20e5d2c42fa9 to your computer and use it in GitHub Desktop.
Save dpriskorn/424bf4dc984176c7353a20e5d2c42fa9 to your computer and use it in GitHub Desktop.
Copy on select implementation for AutoHotkey
;; source https://autohotkey.com/board/topic/44064-copy-on-select-implementation/
cos_mousedrag_treshold := 20 ; pixels
#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
sendinput ^c
}
return
~mbutton::
WinGetClass cos_class, A
if (cos_class == "Emacs")
SendInput ^y
else
SendInput ^v
return
#IfWinNotActive
;; clipx
^mbutton::
sendinput ^+{insert}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment