Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Include <GuiConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <SendMessage.au3>
- ;#include <IE.au3>
- #Include <File.au3>
- #include <WinHTTP.au3>
- FileInstall("P:\crystal2-lay-patcher\tlo.bmp", @TempDir& "\tlo.bmp")
- FileInstall("P:\crystal2-lay-patcher\pasek.bmp", @TempDir& "\pasek.bmp")
- FileInstall("P:\crystal2-lay-patcher\0.gif", @TempDir& "\0.gif")
- $hSession = _WinHttpOpen("User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0")
- $hConnect = _WinHttpConnect($hSession, "patcher.crystal2.pl")
- Global Const $SC_DRAGMOVE = 0xF012
- Global $can_start = 0
- Global $Server = "Crystal2"
- Opt("GUIOnEventMode", 1)
- ################################## GUI #####################################
- $Form1 = GUICreate("Form1", 699, 369, -1, -1, BitOR($WS_POPUP,$WS_BORDER))
- GUISetOnEvent($GUI_EVENT_CLOSE, "zamknij")
- $Zamknij = GUICtrlCreateButton("", 495, 320, 150, 30)
- GUICtrlSetCursor (-1, 0)
- GUICtrlSetOnEvent(-1, "zamknij")
- _GuiCtrlMakeTrans(-1,1)
- GUICtrlSetTip(-1, "Kliknij aby zamknąć Patchera "&$Server&".")
- $opcje = GUICtrlCreateButton("", 45, 320, 150, 30)
- GUICtrlSetCursor (-1, 0)
- GUICtrlSetOnEvent(-1, "opcje")
- _GuiCtrlMakeTrans(-1,1)
- GUICtrlSetTip(-1, "Kliknij aby uruchomić ustawienia gry "&$Server&".")
- $start = GUICtrlCreateButton("", 270, 320, 150, 30)
- GUICtrlSetCursor (-1, 0)
- GUICtrlSetOnEvent(-1, "start")
- _GuiCtrlMakeTrans(-1,1)
- GUICtrlSetTip(-1, "Kliknij aby uruchomić klient gry "&$Server&".")
- GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "sendmasage")
- $Pic1 = GUICtrlCreatePic(@TempDir & "\tlo.bmp", 0, 0, 699, 369)
- $newsy_tekst = (_WinHttpSimpleRequest($hConnect, "GET", "/"))
- GUISetFont(11, 400, 1, "Tahoma")
- $Label1 = GUICtrlCreateLabel($newsy_tekst, 35, 165, 700, 80)
- $Label2 = GUICtrlCreateLabel("", 24, 253, 500, 17)
- GUICtrlSetColor($Label1, 0xFFFFFF)
- GUICtrlSetBkColor($Label1, -2)
- GUICtrlSetColor($Label2, 0xFFFFFF)
- GUICtrlSetBkColor($Label2, -2)
- $Pic2 = GUICtrlCreatePic(@TempDir&"\0.gif", 28, 284, 647, 17)
- GUISetBkColor(0x000000)
- GUICtrlSetState(-1, $GUI_DISABLE)
- GUISetState(@SW_SHOW)
- _WinHttpCloseHandle($hConnect)
- _WinHttpCloseHandle($hSession)
- ################################ END GUI ###################################
- ################################ FUNKCJE ###################################
- Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)
- Local $pHwnd, $nHwnd, $aPos, $a
- $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
- If $hWnd = 0 then Return SetError(1,1,0)
- $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
- If $pHwnd[0] = 0 then Return SetError(1,2,0)
- $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
- If @error then Return SetError(1,3,0)
- $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
- If $nHwnd = 0 then Return SetError(1,4,0)
- $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
- If $a[0] = 0 then Return SetError(1,5,0)
- If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
- GUISetState(@SW_Show,$nHwnd);show the new child gui
- WinSetTrans($nHwnd,"",$iTrans);set the transparency
- If @error then Return SetError(1,7,0)
- GUISwitch($pHwnd[0]);switch back to the parent Gui
- Return $nHwnd;Return the handle for the new Child gui
- EndFunc
- Func patch()
- FileDelete("patcher.log")
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - -------------------------------------"&@CRLF)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - ----- Crystal 2 Patcher 1.1 -----"&@CRLF)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - --------- Wykonał Endymion_ ---------"&@CRLF)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - -------------------------------------"&@CRLF)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Autopatcher Crystal2 startuje..."&@CRLF)
- DirCreate("pack")
- DirCreate("lib")
- DirCreate("upload")
- $listadl = InetGet("http://www.patcher.crystal2.pl/lista.txt", @ScriptDir &"/lista.txt", 1, 1)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Pobieranie informacji o aktualizacji..."&@CRLF)
- While InetGetInfo($listadl, 2) = False
- GuiCtrlSetData($Label2, "Pobieranie informacji o aktualizacji...")
- Sleep(500)
- WEnd
- $file = FileOpen("lista.txt", 0)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Sprawdzanie listy plików do pobrania..."&@CRLF)
- $lines = _FileCountLines("lista.txt")
- $lines1 = _FileCountLines($file)
- $plH = PluginOpen("MD5Hash.dll")
- GuiCtrlSetData($Label2, "Trwa obliczanie sum kontrolnych plików...")
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Trwa obliczanie sum kontrolnych plików..."&@CRLF)
- For $i=$lines To 1 Step -1
- $chars = FileReadLine($file, $lines)
- $array = StringSplit($chars, ';', 1)
- $sumaMD5 = MD5Hash(@ScriptDir&"/"&$array[1], 1, True)
- if String($sumaMD5) <> String($array[2]) Then
- FileWrite("dl.txt", $array[1] & @CRLF)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Plik "&$array[1]&" wymaga aktualizacji. Dodano do kolejki."&@CRLF)
- EndIf
- $lines = $lines-1
- Next
- FileClose($file)
- PluginClose($plH)
- $file2 = FileOpen("dl.txt.", 0)
- $lines2 = _FileCountLines("dl.txt")
- $lines3 = _FileCountLines("dl.txt")
- For $i2=$lines2 To 1 Step -1
- $chars2 = FileReadLine($file2, $lines2)
- $download = InetGet("http://www.patcher.crystal2.pl/"&$chars2, @ScriptDir &"/"&$chars2, 1, 1)
- $info = InetGetInfo($download)
- $predkosc = Round(InetGetInfo($download, 0)/1024, 0)
- Sleep(1000)
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Pobieranie pliku "&$chars2&@CRLF)
- While InetGetInfo($download, 2) = False
- $ile_pobrane = InetGetInfo($download, 0)
- GuiCtrlSetData($Label2, "Pobieranie pliku: "& $chars2 & " - " & Round(InetGetInfo($download, 0)/1024) & " / " & Round(InetGetInfo($download, 1)/1024, 0) & " KB")
- $predkosc = (InetGetInfo($download, 0) - $ile_pobrane)/1024
- Sleep(1)
- WEnd
- sleep(100)
- $lines2 = $lines2-1
- ;MsgBox(0,"", "lines2 = "&$lines2 & @CRLF & "Lines3 = " & $lines3)
- $procenty = $lines3 - $lines2
- $procenty2 = $procenty/$lines3
- $pasek = Round($procenty2*647, 0)
- ;MsgBox(0,"", $pasek &@CRLF&$procenty&@CRLF&$procenty2)
- If $pasek == 0 Then
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
- Else
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, $pasek, 17)
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, $pasek, 17)
- EndIf
- Next
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
- $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
- GuiCtrlSetData($Label2, "Twój klient gry jest aktualny.")
- FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Zakończono sprawdzanie aktualizacji..."&@CRLF)
- FileDelete("dl.txt")
- FileDelete("lista.txt")
- $can_start = 1
- EndFunc
- Func zamknij()
- Exit
- EndFunc
- Func opcje()
- run("config.exe")
- EndFunc
- Func sendmasage()
- _SendMessage($Form1, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
- EndFunc
- Func start()
- if $can_start = 0 Then
- MsgBox(48, "Błąd startu!", "Nie mozesz wystartować gry podczas patchowania!")
- Else
- run("Crystal2.exe")
- EndIf
- EndFunc
- ############################ END FUNKCJE ###################################
- sleep(200)
- patch()
- While 1
- sleep(100)
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment