-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDragKing.ahk
404 lines (348 loc) · 11.1 KB
/
DragKing.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
;DragKing
; Automatically copy selections using mouse or Ctrl-C.
; Reports number of selected chars, words and lines.
;Skrommel @2005
#SingleInstance,Force
SetBatchLines,-1
CoordMode,Mouse,Screen
applicationname=DragKing
SysGet,xdrag,68
SysGet,ydrag,69
Gosub,INIREAD
Gosub,TRAYMENU
If startdisabled=1
Gosub,SWAP
Return
~^c::
Gosub,COPY
Return
~LButton::
MouseGetPos,oldmx,oldmy,oldwinid
Return
~LButton Up::
MouseGetPos,mx,my,winid
VarSetCapacity(rect, 16)
DllCall("GetClientRect", "uint", oldwinid, "uint", &rect)
rect_left :=NumGet(rect,0, "int")
rect_top :=NumGet(rect,4, "int")
rect_right :=NumGet(rect,8, "int")
rect_bottom:=NumGet(rect,12,"int")
If (winid=oldwinid And (mx<oldmx-xdrag Or mx>oldmx+xdrag Or my<oldmy-ydrag Or my>oldmy+ydrag))
If (oldmx>=rect_left And oldmx<=rect_right And oldmy>=rect_top And oldmy<=rect_bottom)
Gosub,COPY
ticks=%A_TickCount%
difticks=%ticks%
EnvSub,difticks,%oldticks%
If difticks<400
If (oldmx>=rect_left And oldmx<=rect_right And oldmy>=rect_top And oldmy<=rect_bottom)
Gosub,Copy
oldticks=%ticks%
Return
~+LButton Up::
~^LButton Up::
Gosub,COPY
Return
COPY:
Sleep,400 ;Wait for doubleclick to select
clipall=%Clipboardall%
Clipboard=
Send,^c
ClipWait,1
If Clipboard=
Clipboard=%clipall%
Else
Gosub,TRAYINFO
Return
INIREAD:
IfNotExist,%applicationname%.ini
{
charstoignore=newlinecarridgereturn
worddelimiters=spacetabnewlinecarridgereturn`,`;`%``:._\/()[]{}<>|§!"#¤=?^~¨*´'@£$€µ
linedelimiters=newlinecarridgereturn
startdisabled=0
showtraytip=1
showtooltip=0
showmsgbox=0
tiptime=3
pastehotkey=~MButton
togglehotkey=
Gosub,INIWRITE
Gosub,ABOUT
}
IniRead,charstoignore,%applicationname%.ini,Settings,charstoignore
IniRead,worddelimiters,%applicationname%.ini,Settings,worddelimiters
IniRead,linedelimiters,%applicationname%.ini,Settings,linedelimiters
IniRead,startdisabled,%applicationname%.ini,Settings,startdisabled
IniRead,showtraytip,%applicationname%.ini,Settings,showtraytip
IniRead,showtooltip,%applicationname%.ini,Settings,showtooltip
IniRead,showmsgbox,%applicationname%.ini,Settings,showmsgbox
IniRead,startdisabled,%applicationname%.ini,Settings,startdisabled
IniRead,tiptime,%applicationname%.ini,Settings,tiptime
IniRead,togglehotkey,%applicationname%.ini,Settings,togglehotkey
IniRead,pastehotkey,%applicationname%.ini,Settings,pastehotkey
StringReplace,charstoignore,charstoignore,space,%A_Space%
StringReplace,charstoignore,charstoignore,tab,%A_Tab%
StringReplace,charstoignore,charstoignore,newline,`n
StringReplace,charstoignore,charstoignore,carridgereturn,`r
StringReplace,worddelimiters,worddelimiters,space,%A_Space%
StringReplace,worddelimiters,worddelimiters,tab,%A_Tab%
StringReplace,worddelimiters,worddelimiters,newline,`n
StringReplace,worddelimiters,worddelimiters,carridgereturn,`r
StringReplace,linedelimiters,linedelimiters,space,%A_Space%
StringReplace,linedelimiters,linedelimiters,tab,%A_Tab%
StringReplace,linedelimiters,linedelimiters,newline,`n
StringReplace,linedelimiters,linedelimiters,carridgereturn,`r
If pastehotkey<>
Hotkey,%pastehotkey%,PASTE,On UseErrorLevel
If togglehotkey<>
Hotkey,%togglehotkey%,SWAP,On UseErrorLevel
Return
INIWRITE:
IniWrite,%charstoignore%,%applicationname%.ini,Settings,charstoignore
IniWrite,%worddelimiters%,%applicationname%.ini,Settings,worddelimiters
IniWrite,%linedelimiters%,%applicationname%.ini,Settings,linedelimiters
IniWrite,%startdisabled%,%applicationname%.ini,Settings,startdisabled
IniWrite,%showtraytip%,%applicationname%.ini,Settings,showtraytip
IniWrite,%showtooltip%,%applicationname%.ini,Settings,showtooltip
IniWrite,%showmsgbox%,%applicationname%.ini,Settings,showmsgbox
IniWrite,%startdisabled%,%applicationname%.ini,Settings,startdisabled
IniWrite,%tiptime%,%applicationname%.ini,Settings,tiptime
IniWrite,%togglehotkey%,%applicationname%.ini,Settings,togglehotkey
IniWrite,%pastehotkey%,%applicationname%.ini,Settings,pastehotkey
Return
TRAYINFO:
clip=%Clipboard%
numofchars=0
StringSplit,chars,clip,%chardelimiters%
Loop,%chars0%
{
If chars%A_Index%<>
{
StringLen,length,chars%A_Index%
numofchars+=%length%
}
}
numofwords=0
StringSplit,words,clip,%worddelimiters%
Loop,%words0%
{
If words%A_Index%<>
numofwords+=1
}
numoflines=0
StringSplit,lines,clip,%linedelimiters%
Loop,%lines0%
{
If lines%A_Index%<>
numoflines+=1
}
If showtraytip=1
Gosub,SHOWTRAYINFO
If showtooltip=1
Gosub,SHOWTOOLINFO
If showmsgbox=1
Gosub,SHOWMSGBOXINFO
Return
SHOWTRAYINFO:
TrayTip,
TrayTip,%applicationname%,Copied`tChars:`t%numofchars%`n`tWords:`t%numofwords%`n`tLines:`t%numoflines%,%tiptime%
Return
SHOWTOOLINFO:
ToolTip,Copied`tChars:`t%numofchars%`n`tWords:`t%numofwords%`n`tLines:`t%numoflines%,0,0
SetTimer,TOOLTIP,% tiptime*1000
Return
SHOWMSGBOXINFO:
MsgBox,0,%applicationname%,Copied`tChars:`t%numofchars%`n`tWords:`t%numofwords%`n`tLines:`t%numoflines%
Return
TOOLTIP:
SetTimer,TOOLTIP,Off
ToolTip,
Return
TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,%applicationname%,SWAP
Menu,Tray,Add,
Menu,Tray,Add,Show last &count...,SHOWMSGBOXINFO
Menu,Tray,Add,
Menu,Tray,Add,&Enabled,SWAP
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,%applicationname%
Menu,Tray,Check,&Enabled
Menu,Tray,Tip,%applicationname%
Return
SETTINGS:
If pastehotkey<>
Hotkey,%pastehotkey%,Off,UseErrorLevel
If togglehotkey<>
Hotkey,%togglehotkey%,Off,UseErrorLevel
StringReplace,charstoignore,charstoignore,%A_Space%,space
StringReplace,charstoignore,charstoignore,%A_Tab%,tab
StringReplace,charstoignore,charstoignore,`n,newline
StringReplace,charstoignore,charstoignore,`r,carridgereturn
StringReplace,worddelimiters,worddelimiters,%A_Space%,space
StringReplace,worddelimiters,worddelimiters,%A_Tab%,tab
StringReplace,worddelimiters,worddelimiters,`n,newline
StringReplace,worddelimiters,worddelimiters,`r,carridgereturn
StringReplace,linedelimiters,linedelimiters,%A_Space%,space
StringReplace,linedelimiters,linedelimiters,%A_Tab%,tab
StringReplace,linedelimiters,linedelimiters,`n,newline
StringReplace,linedelimiters,linedelimiters,`r,carridgereturn
Gui,Margin,30,10
Gui,Add,Tab,xm-20 ym w240 h350,Options|Hotkeys|Counting
Gui,Tab,1
Gui,Add,GroupBox,xm-10 ym+30 w220 h45,Startup
Gui,Add,CheckBox,xm yp+20 vvstartdisabled Checked%startdisabled%,&Start disabled
Gui,Add,GroupBox,xm-10 y+20 w220 h80,Status
Gui,Add,CheckBox,xm yp+20 vvshowtraytip Checked%showtraytip%,Show &tray tip
Gui,Add,CheckBox,xm y+5 vvshowtooltip Checked%showtooltip%,Show t&ool tip
Gui,Add,CheckBox,xm y+5 vvshowmsgbox Checked%showmsgbox%,Show &message box
Gui,Add,GroupBox,xm-10 y+20 w220 h50,Time to show tip (seconds)
Gui,Add,Edit,xm yp+20 vvtiptime,
Gui,Add,UpDown,Limit0-99,%tiptime%
Gui,Tab,2
Gui,Add,GroupBox,xm-10 ym+30 w220 h70,Disable %applicationname%
Gui,Add,Hotkey,xm yp+20 w200 vvtogglehotkey
StringReplace,currenthotkey,togglehotkey,^,Ctrl +%A_Space%
StringReplace,currenthotkey,currenthotkey,!,Alt +%A_Space%
StringReplace,currenthotkey,currenthotkey,+,Shift +%A_Space%
Gui,Add,Text,xm y+5,Current hotkey: %currenthotkey%
Gui,Add,GroupBox,xm-10 y+20 w220 h220,Paste
Gui,Add,Text,xm yp+20,`t* Not all combinations work!
Gui,Add,CheckBox,y+5 vvpastectrl,&Ctrl
Gui,Add,CheckBox,y+5 vvpastealt,&Alt
Gui,Add,CheckBox,y+5 vvpasteshift,S&hift
Gui,Add,CheckBox,y+5 vvpasteleft,&Left mousebutton
Gui,Add,CheckBox,y+5 vvpastemiddle,&Middle mousebutton
Gui,Add,CheckBox,y+5 vvpasteright,&Right mousebutton
Gui,Add,Hotkey,y+5 w200 vvpastehotkey
StringTrimLeft,currenthotkey,pastehotkey,1
StringReplace,currenthotkey,currenthotkey,+,Shift +%A_Space%
StringReplace,currenthotkey,currenthotkey,^,Ctrl +%A_Space%
StringReplace,currenthotkey,currenthotkey,!,Alt +%A_Space%
StringReplace,currenthotkey,currenthotkey,&, +%A_Space%
Gui,Add,Text,xm y+5 w200,Current hotkey: %currenthotkey%
Gui,Tab,3
Gui,Add,Text,xm ym+30 w200,Add the characters you want to ignore or use as delimiters. Note the special space, tab, newline (LF), and carridge return (CR)
Gui,Add,GroupBox,xm-10 y+10 w220 h80,&Line delimiters
Gui,Add,Edit,xm yp+20 w200 h50 vvlinedelimiters,%linedelimiters%
Gui,Add,GroupBox,xm-10 y+20 w220 h80,&Word delimiters
Gui,Add,Edit,xm yp+20 w200 h50 vvworddelimiters,%worddelimiters%
Gui,Add,GroupBox,xm-10 y+20 w220 h80,&Characters to ignore
Gui,Add,Edit,xm yp+20 w200 h50 vvcharstoignore,%charstoignore%
Gui,Tab
Gui,Add,Button,xm-10 y+30 w75 gSETTINGSOK,OK
Gui,Add,Button,x+5 yp w75 gSETTINGSCANCEL,Cancel
Gui,Show,AutoSize,%applicationname% Settings
Return
SETTINGSOK:
Gui,Submit
startdisabled:=vstartdisabled
showtraytip:=vshowtraytip
showtooltip:=vshowtooltip
showmsgbox:=vshowmsgbox
If vtogglehotkey<>
togglehotkey:=vtogglehotkey
hotkey=
If vpastectrl=1
hotkey=%hotkey%^
If vpastealt=1
hotkey=%hotkey%!
If vpasteshift=1
hotkey=%hotkey%+
If vpasteleft=1
hotkey:=hotkey "LButton & "
If vpastemiddle=1
hotkey:=hotkey "MButton & "
If vpasteright=1
hotkey:=hotkey "RButton & "
If vpastehotkey<>
hotkey=%hotkey%%vpastehotkey%
StringRight,end,hotkey,3
If (end=" & ")
StringTrimRight,hotkey,hotkey,3
If hotkey<>
pastehotkey=~%hotkey%
Gosub,INIWRITE
Gosub,INIREAD
Gosub,SETTINGSCANCEL
Return
SETTINGSCANCEL:
Gui,DESTROY
If pastehotkey<>
Hotkey,%pastehotkey%,PASTE,On UseErrorLevel
If togglehotkey<>
Hotkey,%togglehotkey%,SWAP,On UseErrorLevel
Return
SWAP:
Menu,Tray,ToggleCheck,&Enabled
Suspend,Toggle
Return
ABOUT:
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.3
Gui,99:Font
Gui,99:Add,Text,y+10,Automatically copies mouse selections to the clipboard.
Gui,99:Add,Text,y+10,- Reports the number of copied characters, words and lines.
Gui,99:Add,Text,y+10,- Change the settings by choosing Settings in the Tray menu.
Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,99:Font
Gui,99:Add,Text,y+10,For more tools, information and donations, please visit
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font
Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,DonationCoder
Gui,99:Font
Gui,99:Add,Text,y+10,Please support the contributors at
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font
Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,AutoHotkey
Gui,99:Font
Gui,99:Add,Text,y+10,This tool was made using the powerful
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font
Gui,99:Show,,%applicationname% About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return
1HOURSOFTWARE:
Run,http://www.1hoursoftware.com,,UseErrorLevel
Return
DONATIONCODER:
Run,http://www.donationcoder.com,,UseErrorLevel
Return
AUTOHOTKEY:
Run,http://www.autohotkey.com,,UseErrorLevel
Return
99GuiClose:
Gui,99:Destroy
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCur)
Return
WM_MOUSEMOVE(wParam,lParam)
{
Global hCurs
MouseGetPos,,,,ctrl
If ctrl in Static9,Static13,Static17
DllCall("SetCursor","UInt",hCurs)
Return
}
Return
EXIT:
ExitApp
PASTE:
Send,^v
Return