#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
}