-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathDefault.ahk
243 lines (224 loc) · 6.25 KB
/
Default.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
/*
Name : Standard functions, can also be shared by bundle scripts by including LLInit() in your bundle script
Version : 1.0
Date : 20101010
Functions :
- LLInit()
- GetActiveWindowStats()
- Sendkey()
- ClipSet() mod of virclip by Learning one http://www.autohotkey.com/forum/topic56926.html
*/
GetActiveWindowStats() ; Get Active Window & Control
{
global
WinGet, ActiveWindowID, ID, A
WinGet, ActiveWindowProcessName, ProcessName, A ; TODO TODOMC
WinGetClass, ActiveWindowClass, A
ControlGetFocus, ActiveControl, A
WinGetActiveTitle, ActiveWindowTitle
StringReplace, ActiveWindowTitle, ActiveWindowTitle, [, , All
StringReplace, ActiveWindowTitle, ActiveWindowTitle, ], , All
; we can use this in our bundles to make sure we have
; the default functions available to our scripts defined in the bundle
LLInit= ; pass on basic data + functions to script from snippet
(
ActiveWindowID=%ActiveWindowID%
ActiveWindowClass=%ActiveWindowClass%
ActiveControl=%ActiveControl%
ActiveWindowTitle=%ActiveWindowTitle%
PasteDelay=%PasteDelay%
SendMethod=%SendMethod%
#include %A_ScriptDir%\include\default.ahk
)
}
LLInit() ; Fake function call -> If you use this in a snippet script Lintalist will replace this with the variables above from LLInit.
{
;
}
SendKey(Method = 1, Keys = "")
{
; Method: 1 = SendInput
; Method: 2 = SendEvent
; Method: 3 = SendPlay
; Method: 4 = ControlSend
global PasteDelay
Sleep, % PasteDelay
; If ((Save = 1) or (Save = ""))
; ClipSet("s",1) ; safe current content and clear clipboard
; ClearClipboard()
If (Method = 1)
{
WinActivate ahk_id %ActiveWindowID%
SendInput %keys%
}
Else If (Method = 2)
{
WinActivate ahk_id %ActiveWindowID%
SendEvent %keys%
}
Else If (Method = 3)
{
WinActivate ahk_id %ActiveWindowID%
SendPlay %keys%
}
Else If (Method = 4)
{
WinActivate ahk_id %ActiveWindowID%
ControlSend, %ActiveControl%, %keys%, ahk_id %ActiveWindowID%
}
Sleep 50 ; some time to get data to clipboard
; If (Restore = 1)
; Clipboard:=ClipSet("g",2) ; restore
Return
}
; mod of virclip by Learning one http://www.autohotkey.com/forum/topic56926.html
/* original VirClip tasks: (renamed to ClipSet for Lintalist)
"c" or "Copy" ; copies just text. (Clipboard)
"ca" or "CopyAll" ; copies all data; text, pictures, formatting. (ClipboardAll)
"x" or "Cut"
"xa" or "CutAll"
"v" or "Paste"
"vt" or "PasteText" ; pastes only text from virtual clipboard.
"e" or "Empty"
"ea" or "EmptyAll"
"g" or "Get"
"s" or "Set"
"a" or "Append"
"p" or "Prepend"
"as" or "AppendSelected" ; Appends selected text, not pictures etc.
"ps" or "PrependSelected"
"uc" or "UpperCase"
"lc" or "LowerCase"
"tc" or "TitleCase"
*/
ClipSet(Task,ClipNum=1,SendMethod=1,Value="") ; by Learning one http://www.autohotkey.com/forum/topic56926.html
{
Static Clip1, Clip2, Clip3, Clip4
if ClipNum not between 1 and 30
Return
IsClipEmpty := (Clipboard = "") ? 1 : 0
if (task = "c" or task = "ca" or task = "x" or task = "xa" or task = "Copy" or task = "CopyAll" or task = "Cut" or task = "CutAll")
{
ClipboardBackup := ClipboardAll
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
if (task = "c" or task = "ca" or task = "Copy" or task = "CopyAll")
SendKey(SendMethod, "^c")
Else
SendKey(SendMethod, "^x")
if (task = "c" or task = "x" or task = "Copy" or task = "Cut") {
ClipWait, 0.5
if !(Clipboard = "")
Clip%ClipNum% := Clipboard
}
Else {
ClipWait, 0.5, 1
if !(Clipboard = "")
Clip%ClipNum% := ClipboardAll
}
Clipboard := ClipboardBackup
if !IsClipEmpty
ClipWait, 0.5, 1
Return Clip%ClipNum%
}
else if (task = "v" or task = "vt" or task = "Paste" or task = "PasteText") {
if (Clip%ClipNum% = "")
Return
ClipboardBackup := ClipboardAll
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
Clipboard := Clip%ClipNum%
ClipWait, 0.5, 1
Sleep, 40
if (task = "vt" or task = "PasteText") {
Clipboard := Clipboard
ClipWait, 0.5
Sleep, 30
}
SendKey(SendMethod, "^v")
Sleep, 20
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
Clipboard := ClipboardBackup
if !IsClipEmpty
ClipWait, 0.5, 1
Return Clip%ClipNum%
}
else if (task = "e" or task = "Empty") {
Clip%ClipNum% =
Return
}
else if (task = "ea" or task = "EmptyAll") {
Loop, 30
Clip%A_Index% =
Return
}
else if (task = "g" or task = "Get")
Return Clip%ClipNum%
else if (task = "s" or task = "Set") {
Clip%ClipNum% := Value
Return Clip%ClipNum%
}
else if (task = "a" or task = "Append") {
Clip%ClipNum% .= Value
Return Clip%ClipNum%
}
else if (task = "p" or task = "Prepend") {
Clip%ClipNum% := Value Clip%ClipNum%
Return Clip%ClipNum%
}
else if (task = "as" or task = "ps" or task = "AppendSelected" or task = "PrependSelected") {
ClipboardBackup := ClipboardAll
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
SendKey(SendMethod, "^c")
ClipWait, 0.5
if !(Clipboard = "") {
if (Clip%ClipNum% = "")
Clip%ClipNum% := Clipboard
Else {
if (task = "as" or task = "AppendSelected")
Clip%ClipNum% .= value Clipboard
Else
Clip%ClipNum% := Clipboard Value Clip%ClipNum%
}
}
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
Clipboard := ClipboardBackup
if !IsClipEmpty
ClipWait, 0.5, 1
Return Clip%ClipNum%
}
else if (task = "uc" or task = "UpperCase") {
StringUpper, Clip%ClipNum%, Clip%ClipNum%
Return Clip%ClipNum%
}
else if (task = "lc" or task = "LowerCase") {
StringLower, Clip%ClipNum%, Clip%ClipNum%
Return Clip%ClipNum%
}
else if (task = "tc" or task = "TitleCase") {
StringUpper, Clip%ClipNum%, Clip%ClipNum%, T
Return Clip%ClipNum%
}
}
ClearClipboard()
{
While !(Clipboard = "")
{
Clipboard =
Sleep, 10
}
Return
}