SetBatchLines -1 secToTime sec spliter sec 3600 sec-h 3600 60 sec-h 36

  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
SetBatchLines, -1
secToTime(sec, spliter := 0)
{
h := sec/3600 ^ 0
m := (sec-h*3600)/60 ^ 0
s := sec-h*3600-m*60
Return (h < 10 ? "0" h : h) (spliter ? ":" : " ч. ") (m < 10 ? "0" m : m) (spliter ? ":" : " мин. ") (s < 10 ? "0" s : s) (spliter ? "" : " сек. ")
}
getInclinationByNumber(int, _array)
{
array := []
for k, v in _array
{
if (RegExMatch(v, "\$_COUNT"))
array[k] := RegExReplace(v, "\$_COUNT", int)
Else
array[k] := int " " v
}
if (Mod(int, 100) >= 11 && Mod(int, 100) <= 19)
out := array[1]
else if (Mod(int, 10) == 1)
out := array[2]
else if (Mod(int, 10) >= 2 && Mod(int, 10) <= 4)
out := array[3]
return (out ? out : array[1])
}
StrLow(str)
{
StringLower, str, str
return str
}
StrUp(str)
{
StringUpper, str, str
return str
}
Rand(min, max)
{
Random, out, min, max
Return out
}
array_implode(array, str := "`n")
{
if (!IsObject(array))
Return
out := ""
for k, v in array
out .= v str
Return Trim(out, str)
}
array_mixValue(a)
{
i := a.MaxIndex()
While (i > 0)
{
Random j, 1, i
x := a[i]
a[i] := a[j]
a[j] := x
--i
}
Return a
}
array_splice(array, count := 0, start := 1)
{
new_array := {}
count_i := 1
for k, v in array
{
if (A_Index < start)
continue
if (count >= count_i || !count)
{
count_i++
new_array.Push(v)
}
else
break
}
return new_array
}
splitStringLimit(text, limit)
{
out := []
while RegExMatch(text, "xO)(?<=\s|^) ( ([^`r`n]){1," . limit . "} | (?2)+? ) (\s|$)", match, match ? match.Pos + match.Len : 1)
out.Push(match[1])
Return out
}
GetOSVersion()
{
VarSetCapacity(v,148), NumPut(148,v)
DllCall("GetVersionEx", "uint", &v)
os := NumGet(v,4) "." NumGet(v,8) "." SubStr("0000" NumGet(v,12), -3)
if (RegExMatch(os, "^(\d+)\.(\d+)", out_pars))
{
if (out_pars1 == 10)
Return 10
else if (out_pars1 == 6 && out_pars2 > 1)
Return 8
}
Return 7
}
RandomMessage(array)
{
Return (IsObject(array) ? array[Rand(1, array.MaxIndex())] : array)
}
isInteger(num)
{
return num^0 == num
}
curl(method, adress, package := "", user_agent := "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36 u01-05", error_log := 0, time_out := 0)
{
if (GetOSVersion() == 7)
{
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560
}
if (!RegExMatch(adress, "^http[s]?:\/\/.*\..*$"))
return error_log ? "Invalid URL adress (#1)" : false
else if (!DllCall("Wininet.dll\InternetGetConnectedState", "Str", 0x20, "Int", 0))
return error_log ? "Not internet connection (#2)" : false
try
{
temp_package := ""
for k, v in package
temp_package .= (A_Index > 1 ? "&" : (method == "POST" ? "" : "?")) k "=" (IsObject(v) ? JSON.Encode(v) : v)
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
http.Open(method, adress (method != "POST" ? temp_package : ""), false)
http.SetRequestHeader("Referer", adress)
http.SetRequestHeader("User-Agent", user_agent)
http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
http.SetRequestHeader("Pragma", "no-cache")
http.SetRequestHeader("Cache-Control", "no-cache, no-store")
http.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
http.Send((method == "POST" ? temp_package : ""))
http.WaitForResponse(time_out ? time_out : 0)
if (!StrLen(http.ResponseText))
return error_log ? "Empty response (#3)" : false
else
{
if (http.Status !== 200)
return error_log ? http.Status "(" http.StatusText ") (#4)" : false
else
{
ResponseText := RegExReplace(http.ResponseText, "<br>", "`n")
ResponseText := RegExReplace(ResponseText, "<t>", "`t")
ResponseText := RegExReplace(ResponseText, "<br \/>", "`n")
return ResponseText
}
}
}
catch e
return error_log ? e.message "(#5)" : false
}
Copy(Text, LocaleID=0x419)
{
CF_TEXT:=1, CF_LOCALE:=16, GMEM_MOVEABLE:=2
TextLen :=StrLen(Text)
HmemText :=DllCall("GlobalAlloc", "UInt", GMEM_MOVEABLE, "UInt", TextLen+1) ; Запрос перемещаемой
HmemLocale:=DllCall("GlobalAlloc", "UInt", GMEM_MOVEABLE, "UInt", 4) ; памяти, возвращаются хэндлы.
If(!HmemText || !HmemLocale)
Return
PtrText :=DllCall("GlobalLock", "UInt", HmemText) ; Фиксация памяти, хэндлы конвертируются
PtrLocale :=DllCall("GlobalLock", "UInt", HmemLocale) ; в указатели (адреса).
DllCall("msvcrt\memcpy", "UInt", PtrText, "Str", Text, "UInt", TextLen+1, "Cdecl") ; Копирование текста.
NumPut(LocaleID, PtrLocale+0) ; Запись идентификатора локали.
DllCall("GlobalUnlock", "UInt", HmemText) ; Расфиксация памяти.
DllCall("GlobalUnlock", "UInt", HmemLocale)
If not DllCall("OpenClipboard", "UInt", 0) ; Открытие буфера обмена.
{
DllCall("GlobalFree", "UInt", HmemText) ; Освобождение памяти,
DllCall("GlobalFree", "UInt", HmemLocale) ; если открыть не удалось.
Return
}
DllCall("EmptyClipboard") ; Очистка.
DllCall("SetClipboardData", "UInt", CF_TEXT, "UInt", HmemText) ; Помещение данных.
DllCall("SetClipboardData", "UInt", CF_LOCALE, "UInt", HmemLocale)
DllCall("CloseClipboard") ; Закрытие.
}
ClipGetText(CodePage=1251)
{
CF_TEXT:=1, CF_UNICODETEXT:=13, Format:=0
If not DllCall("OpenClipboard", "UInt", 0) ; Открытие буфера обмена.
Return
Loop
{
Format:=DllCall("EnumClipboardFormats", "UInt", Format) ; Перебор форматов.
If(Format=0 || Format=CF_TEXT || Format=CF_UNICODETEXT)
Break
}
If(Format=0) { ; Текста не найдено.
DllCall("CloseClipboard")
Return
}
If(Format=CF_TEXT)
{
HmemText:=DllCall("GetClipboardData", "UInt", CF_TEXT) ; Получение хэндла данных.
PtrText :=DllCall("GlobalLock", "UInt", HmemText) ; Конвертация хэндла в указатель.
TextLen :=DllCall("msvcrt\strlen", "UInt", PtrText, "Cdecl") ; Измерение длины найденного текста.
VarSetCapacity(Text, TextLen+1) ; Переменная под этот текст.
DllCall("msvcrt\memcpy", "Str", Text, "UInt", PtrText, "UInt", TextLen+1, "Cdecl") ; Текст в переменную.
DllCall("GlobalUnlock", "UInt", HmemText) ; Расфиксация памяти.
}
Else If(Format=CF_UNICODETEXT)
{
HmemTextW:=DllCall("GetClipboardData", "UInt", CF_UNICODETEXT)
PtrTextW :=DllCall("GlobalLock", "UInt", HmemTextW)
TextLen :=DllCall("msvcrt\wcslen", "UInt", PtrTextW, "Cdecl")
VarSetCapacity(Text, TextLen+1)
DllCall("WideCharToMultiByte", "UInt", CodePage, "UInt", 0, "UInt", PtrTextW
, "Int", TextLen+1, "Str", Text, "Int", TextLen+1
, "UInt", 0, "Int", 0) ; Конвертация из Unicode в ANSI.
DllCall("GlobalUnlock", "UInt", HmemTextW)
}
DllCall("CloseClipboard") ; Закрытие.
Return Text
}
sortArray(array, key := "", desc := 1, string := 0)
{
str := "", d1 := Chr(1), d2 := Chr(2)
for k, v in array
str .= (str = "" ? "" : d1) . (key ? v[key] : v) . d2 . k
Sort, str, % (desc ? "R" : "") (string ? "" : "N") "D" . d1
newArr := []
Loop, parse, str, % d1
newArr.Push(array[ RegExReplace(A_LoopField, ".+" . d2) ])
return newArr
}
objHasValue(array, find, key := "")
{
for k, v in array
if (key && v[key] == find) || v == find
return 1
return 0
}
class JSON
{
Decode(jsonStr)
{
; Create the COM object we'll use to decode the string
SC := ComObjCreate("ScriptControl")
SC.Language := "JScript"
ComObjError(false)
; This next part is a JScript (similar to JavaScript), not AHK, just FYI
; This does the actual parsing
jsCode =
(
function arrangeForAhkTraversing(obj){
if(obj instanceof Array){
for(var i=0 ; i<obj.length ; ++i)
obj[i] = arrangeForAhkTraversing(obj[i]) ;
return ['array',obj] ;
}else if(obj instanceof Object){
var keys = [], values = [] ;
for(var key in obj){
keys.push(key) ;
values.push(arrangeForAhkTraversing(obj[key])) ;
}
return ['object',[keys,values]] ;
}else
return [typeof obj,obj] ;
}
)
; Decode the JSON into an array (call the JS function above) using the COM object, then return an AHK object
SC.ExecuteStatement(jsCode "; obj=" jsonStr)
return this.convertJScriptObjToAhks( SC.Eval("arrangeForAhkTraversing(obj)") )
}
convertJScriptObjToAhks(jsObj)
{
if (jsObj[0]="object")
{
obj := {}, keys := jsObj[1][0], values := jsObj[1][1]
loop % keys.length
obj[keys[A_INDEX-1]] := this.convertJScriptObjToAhks( values[A_INDEX-1] )
return obj
}
else if (jsObj[0]="array")
{
array := []
loop % jsObj[1].length
array.insert(this.convertJScriptObjToAhks( jsObj[1][A_INDEX-1] ))
return array
}
else
return jsObj[1]
}
Encode(obj)
{
str := ""
array := true
for k in obj {
if (k == A_Index)
continue
array := false
break
}
for a, b in obj
str .= (array ? "" : "'" a "': ") . (IsObject(b) ? this.Encode(b) : "'" b "'") . ", "
str := RTrim(str, " ,")
return (array ? "[" str "]" : "{" str "}")
}
}