-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_on_select.ahk
63 lines (53 loc) · 1.2 KB
/
copy_on_select.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
mousedrag_treshold := 20 ; pixels
middleclick_available := 15 ; seconds
Hotkey mbutton, paste_selection
Hotkey mbutton, off
Hotkey rbutton, cancel_paste
Hotkey rbutton, off
#IfWinNotActive ahk_class ConsoleWindowClass
~lButton::
MouseGetPos, mousedrag_x, mousedrag_y
keywait lbutton
mousegetpos, mousedrag_x2, mousedrag_y2
if (abs(mousedrag_x2 - mousedrag_x) > mousedrag_treshold
or abs(mousedrag_y2 - mousedrag_y) > mousedrag_treshold)
{
wingetclass class, A
if (class == "Emacs")
sendinput !w
else
sendinput ^c
settimer follow_mouse, 100
settimer cleanup, % middleclick_available * 1000
hotkey mbutton, on
hotkey rbutton, on
}
return
#IfWinNotActive
follow_mouse:
tooltip copy
return
paste_selection:
sendinput {lbutton}
WinGetClass class, A
if (class == "Emacs")
SendInput ^y
else
SendInput ^v
gosub cleanup
return
cancel_paste:
sendinput {rbutton}
gosub cleanup
return
cleanup:
Hotkey mbutton, off
Hotkey rbutton, off
SetTimer cleanup, off
settimer follow_mouse, off
tooltip
Return
;; clipx
^mbutton::
sendinput ^+{insert}
return