NoEnv SingleInstance Force Persistent Download_NewVersion http mvd cza

  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
#NoEnv
#SingleInstance, Force
#Persistent
Download_NewVersion("http://mvd.czar-script.ru/Orange/filles/MVD-Orange.exe", A_ScriptName)
global mainPach := ""
global server := ["Galaxy", "Lite", "Evo", "Trie", "Sky", "MagicRPG", "Hard", "Epsilon"]
; SerchScreenPenta()
MsgBox % mainPach
SerchScreenPenta()
{
While(True)
{
WinGetTitle, title, A
if (RegExMatch(title, "Pentacraft\s+(?<Server>.*)\s+\[.*\]\s+\[.*\]", out) && searchInArray(outServer, server))
{
for Process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where Name='javaw.exe'")
RegExMatch(process.ExecutablePath, "(?<Pach>.*)\\.*\\bin\\javaw\.exe", out)
pach := outPach "\" outServer "\logs\latest.log"
if (FileExist(pach))
{
mainPach := pach
Break
}
pach := outPach "\" outServer "-Shaders\logs\latest.log"
if (FileExist(pach))
{
mainPach := pach
Break
}else{
MsgBox, 0x10, Ошибка, % "Не удалось найти путь.`nОбратитесь к разработчику скрипта за помощью.`n" pach
}
}
}
}
searchInArray(param, arr)
{
for key, value in arr
if (value == param)
Return True
Return 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")
}
Download(url, file, callback) {
static vt
if !VarSetCapacity(vt) {
VarSetCapacity(vt, A_PtrSize*11), nPar := "31132253353"
Loop Parse, nPar
NumPut(RegisterCallback("DL_Progress", "F", A_LoopField, A_Index-1), vt, A_PtrSize*(A_Index-1))
}
if !(IsObject(callback) || (callback := Func(callback)))
return !(ErrorLevel := 1)
VarSetCapacity(bobj, A_PtrSize*2), NumPut(&callback, NumPut(&vt, bobj)), VarSetCapacity(tn, 520)
if (0 = DllCall("urlmon\URLDownloadToCacheFile", "ptr", 0, "str", url, "str", tn, "uint", 260, "uint", 0x10, "ptr", &bobj))
FileCopy %tn%, %file%, 1
else
ErrorLevel := 1
return !ErrorLevel
}
DL_Progress( pthis, nP=0, nPMax=0, nSC=0, pST=0 ) {
if A_EventInfo = 6
fn := Object(NumGet(pthis+A_PtrSize)), %fn%(np, npMax)
return 0
}
Download_NewVersion_Progress(n, nMax) {
if !nMax
return
width := (n*100/nMax)
GuiControl,Download:, DownProgress, % width
Size := DownloadSize(n) " / " DownloadSize(nMax)
GuiControl,Download:Text ,DownProgressSize, % Size
Sleep 10
}
DownloadSize(n) {
n /= 1024
if (n > 1024)
return Round(n/1024, 2) " MB"
return Round(n, 2) " KB"
}
Download_NewVersion(url_script,filename) {
global wb
wb.Stop()
file := A_ScriptDir "\" filename "_new"
Oldfile := A_ScriptDir "\" filename
Sleep 10
if !Download(url_script, file, "Download_NewVersion_Progress") {
msg.internet()
return
}
FileGetSize, sizeofnew, %file%
if (file > 300000)
Run, %comspec% /c ping -n 4 127.0.0.1 >nul && copy /Y "%file%" "%Oldfile%" && "%Oldfile%", , hide
else
{
msg.internet()
}
ExitApp
}