Endymionek

Endymion || AutoIT Patcher

May 10th, 2013
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.53 KB | None | 0 0
  1. #Include <GuiConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <StaticConstants.au3>
  4. #include <WindowsConstants.au3>
  5. #include <SendMessage.au3>
  6. ;#include <IE.au3>
  7. #Include <File.au3>
  8. #include <WinHTTP.au3>
  9.  
  10. FileInstall("P:\crystal2-lay-patcher\tlo.bmp", @TempDir& "\tlo.bmp")
  11. FileInstall("P:\crystal2-lay-patcher\pasek.bmp", @TempDir& "\pasek.bmp")
  12. FileInstall("P:\crystal2-lay-patcher\0.gif", @TempDir& "\0.gif")
  13.  
  14.  
  15.  
  16.  
  17. $hSession = _WinHttpOpen("User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0")
  18. $hConnect = _WinHttpConnect($hSession, "patcher.crystal2.pl")
  19.  
  20.  
  21. Global Const $SC_DRAGMOVE = 0xF012
  22. Global $can_start = 0
  23. Global $Server = "Crystal2"
  24. Opt("GUIOnEventMode", 1)
  25.  
  26. ################################## GUI #####################################
  27. $Form1 = GUICreate("Form1", 699, 369, -1, -1,  BitOR($WS_POPUP,$WS_BORDER))
  28. GUISetOnEvent($GUI_EVENT_CLOSE, "zamknij")
  29. $Zamknij = GUICtrlCreateButton("", 495, 320, 150, 30)
  30. GUICtrlSetCursor (-1, 0)
  31. GUICtrlSetOnEvent(-1, "zamknij")
  32. _GuiCtrlMakeTrans(-1,1)
  33. GUICtrlSetTip(-1, "Kliknij aby zamknąć Patchera "&$Server&".")
  34. $opcje = GUICtrlCreateButton("", 45, 320, 150, 30)
  35. GUICtrlSetCursor (-1, 0)
  36. GUICtrlSetOnEvent(-1, "opcje")
  37. _GuiCtrlMakeTrans(-1,1)
  38. GUICtrlSetTip(-1, "Kliknij aby uruchomić ustawienia gry "&$Server&".")
  39. $start = GUICtrlCreateButton("", 270, 320, 150, 30)
  40. GUICtrlSetCursor (-1, 0)
  41. GUICtrlSetOnEvent(-1, "start")
  42. _GuiCtrlMakeTrans(-1,1)
  43. GUICtrlSetTip(-1, "Kliknij aby uruchomić klient gry "&$Server&".")
  44. GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "sendmasage")
  45. $Pic1 = GUICtrlCreatePic(@TempDir & "\tlo.bmp", 0, 0, 699, 369)
  46. $newsy_tekst = (_WinHttpSimpleRequest($hConnect, "GET", "/"))
  47. GUISetFont(11, 400, 1, "Tahoma")
  48. $Label1 = GUICtrlCreateLabel($newsy_tekst, 35, 165, 700, 80)
  49. $Label2 = GUICtrlCreateLabel("", 24, 253, 500, 17)
  50. GUICtrlSetColor($Label1, 0xFFFFFF)
  51. GUICtrlSetBkColor($Label1, -2)
  52. GUICtrlSetColor($Label2, 0xFFFFFF)
  53. GUICtrlSetBkColor($Label2, -2)
  54. $Pic2 = GUICtrlCreatePic(@TempDir&"\0.gif", 28, 284, 647, 17)
  55. GUISetBkColor(0x000000)
  56. GUICtrlSetState(-1, $GUI_DISABLE)
  57. GUISetState(@SW_SHOW)
  58. _WinHttpCloseHandle($hConnect)
  59. _WinHttpCloseHandle($hSession)
  60. ################################ END GUI ###################################
  61.  
  62.  
  63.  
  64.  
  65.  
  66. ################################ FUNKCJE ###################################
  67. Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)
  68.     Local $pHwnd, $nHwnd, $aPos, $a
  69.     $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
  70.     If $hWnd = 0 then Return SetError(1,1,0)
  71.     $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
  72.     If $pHwnd[0] = 0 then Return SetError(1,2,0)
  73.     $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
  74.     If @error then Return SetError(1,3,0)
  75.     $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
  76.     If $nHwnd = 0 then Return SetError(1,4,0)
  77.     $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
  78.     If $a[0] = 0 then Return SetError(1,5,0)
  79.     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
  80.     GUISetState(@SW_Show,$nHwnd);show the new child gui
  81.     WinSetTrans($nHwnd,"",$iTrans);set the transparency
  82.     If @error then Return SetError(1,7,0)
  83.     GUISwitch($pHwnd[0]);switch back to the parent Gui
  84.     Return $nHwnd;Return the handle for the new Child gui
  85. EndFunc
  86.  
  87. Func patch()
  88.     FileDelete("patcher.log")
  89.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - -------------------------------------"&@CRLF)
  90.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - -----   Crystal 2 Patcher 1.1   -----"&@CRLF)
  91.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - --------- Wykonał Endymion_ ---------"&@CRLF)
  92.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - -------------------------------------"&@CRLF)
  93.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Autopatcher Crystal2 startuje..."&@CRLF)
  94.     DirCreate("pack")
  95.     DirCreate("lib")
  96.     DirCreate("upload")
  97.     $listadl = InetGet("http://www.patcher.crystal2.pl/lista.txt", @ScriptDir &"/lista.txt", 1, 1)
  98.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Pobieranie informacji o aktualizacji..."&@CRLF)
  99.  
  100.     While InetGetInfo($listadl, 2) = False
  101.         GuiCtrlSetData($Label2, "Pobieranie informacji o aktualizacji...")
  102.         Sleep(500)
  103.     WEnd
  104.  
  105.  
  106.     $file = FileOpen("lista.txt", 0)
  107.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Sprawdzanie listy plików do pobrania..."&@CRLF)
  108.     $lines = _FileCountLines("lista.txt")
  109.     $lines1 = _FileCountLines($file)
  110.  
  111.     $plH = PluginOpen("MD5Hash.dll")
  112.     GuiCtrlSetData($Label2, "Trwa obliczanie sum kontrolnych plików...")
  113.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Trwa obliczanie sum kontrolnych plików..."&@CRLF)
  114.     For $i=$lines To 1 Step -1
  115.         $chars = FileReadLine($file, $lines)
  116.         $array = StringSplit($chars, ';', 1)
  117.         $sumaMD5 = MD5Hash(@ScriptDir&"/"&$array[1], 1, True)
  118.         if String($sumaMD5) <> String($array[2]) Then
  119.             FileWrite("dl.txt", $array[1] & @CRLF)
  120.             FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Plik "&$array[1]&" wymaga aktualizacji. Dodano do kolejki."&@CRLF)
  121.         EndIf
  122.         $lines = $lines-1
  123.     Next
  124.         FileClose($file)
  125.         PluginClose($plH)
  126.  
  127.  
  128.     $file2 = FileOpen("dl.txt.", 0)
  129.     $lines2 = _FileCountLines("dl.txt")
  130.     $lines3 = _FileCountLines("dl.txt")
  131.  
  132.     For $i2=$lines2 To 1 Step -1
  133.         $chars2 = FileReadLine($file2, $lines2)
  134.         $download =  InetGet("http://www.patcher.crystal2.pl/"&$chars2, @ScriptDir &"/"&$chars2, 1, 1)
  135.         $info = InetGetInfo($download)
  136.         $predkosc = Round(InetGetInfo($download, 0)/1024, 0)
  137.         Sleep(1000)
  138.         FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Pobieranie pliku "&$chars2&@CRLF)
  139.         While InetGetInfo($download, 2) = False
  140.             $ile_pobrane = InetGetInfo($download, 0)
  141.             GuiCtrlSetData($Label2, "Pobieranie pliku: "& $chars2 & " - " &  Round(InetGetInfo($download, 0)/1024) & " / " & Round(InetGetInfo($download, 1)/1024, 0) & " KB")
  142.             $predkosc = (InetGetInfo($download, 0) - $ile_pobrane)/1024
  143.             Sleep(1)
  144.         WEnd
  145.  
  146.         sleep(100)
  147.  
  148.         $lines2 = $lines2-1
  149.         ;MsgBox(0,"", "lines2 = "&$lines2 & @CRLF & "Lines3 = " & $lines3)
  150.         $procenty = $lines3 - $lines2
  151.         $procenty2 = $procenty/$lines3
  152.         $pasek = Round($procenty2*647, 0)
  153.         ;MsgBox(0,"", $pasek &@CRLF&$procenty&@CRLF&$procenty2)
  154.         If $pasek == 0 Then
  155.             $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
  156.             $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
  157.         Else
  158.             $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, $pasek, 17)
  159.             $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, $pasek, 17)
  160.         EndIf
  161.  
  162.     Next
  163.     $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
  164.     $Pic2 = GUICtrlCreatePic(@TempDir&"\pasek.bmp", 28, 284, 647, 17)
  165.     GuiCtrlSetData($Label2, "Twój klient gry jest aktualny.")
  166.     FileWrite("patcher.log", @HOUR&":"&@MIN&":"&@SEC&" - Zakończono sprawdzanie aktualizacji..."&@CRLF)
  167.     FileDelete("dl.txt")
  168.     FileDelete("lista.txt")
  169.     $can_start = 1
  170. EndFunc
  171.  
  172. Func zamknij()
  173.     Exit
  174. EndFunc
  175.  
  176. Func opcje()
  177.     run("config.exe")
  178. EndFunc
  179.  
  180. Func sendmasage()
  181.     _SendMessage($Form1, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
  182. EndFunc
  183.  
  184. Func start()
  185.     if $can_start = 0 Then
  186.         MsgBox(48, "Błąd startu!", "Nie mozesz wystartować gry podczas patchowania!")
  187.     Else
  188.         run("Crystal2.exe")
  189.     EndIf
  190. EndFunc
  191.  
  192. ############################ END FUNKCJE ###################################
  193. sleep(200)
  194. patch()
  195.  
  196. While 1
  197.     sleep(100)
  198. WEnd
Advertisement
Add Comment
Please, Sign In to add comment