TrunghieuTH10

Download And Install CocCoc

Aug 22nd, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.99 KB | None | 0 0
  1. #RequireAdmin
  2. Dim $sURL = 'http://files.coccoc.vn/browser/coccoc_vi.exe',$sDir = @TempDir & '\CocCoc_Setup\', $Form1,$Progress1,$sSpeed,$sSize,$spid
  3. If FileExists($sDir) Then DirRemove($sDir,1)
  4. DirCreate($sDir)
  5. $Form1 = GUICreate("", 440, 40, -1, 10, BitOR(0x00800000,0x80000000), BitOR(0x00000008,0x00000080))
  6. _WinAPI_SetLayeredWindowAttributes($Form1, 0xABCDEF, 255)
  7. $Progress1 = GUICtrlCreateProgress(5, 20, 430, 17)
  8. DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Progress1), "wstr", 0, "wstr", 0)
  9. GUICtrlSetStyle($Progress1, 0x01)
  10. GUICtrlSetFont(-1, 8, 700,0, "Tahoma")
  11. $sSize = GUICtrlCreateLabel("0 Kb", 170, 22,130,15,0x0001)
  12. GUICtrlSetBkColor(-1, -2)
  13. GUICtrlSetFont(-1, 8, 700,0, "Tahoma")
  14. GUICtrlCreateLabel("Đang Tải Trình Duyệt Côc Cốc", 55, 1,200,18)
  15. GUICtrlSetFont(-1, 10, 700,0, "Tahoma")
  16. $sSpeed = GUICtrlCreateLabel("", 255, 1,170,18)
  17. GUICtrlSetFont(-1, 10, 700,0, "Tahoma")
  18. GUISetState(@SW_SHOW)
  19. Local $sCocCoc =_InetGetProgress($Progress1, $sSize, $sSpeed, $sURL, $sDir)
  20. If Not @error Then
  21.     MsgBox(064 ,"Thông báo","Tải thành công, chuẩn bị cài đặt"&@CRLF& $sCocCoc,0.5)
  22.     GUIDelete($Form1)
  23.     If Not FileExists($sCocCoc) Then Exit MsgBox(16,'Lỗi - Không tìm thấy file cài đặt', _
  24.     'Có lỗi trong quá trình tải file, vui lòng thử lại',3)
  25.     SplashTextOn('',"Đang cài đặt Cốc Cốc, Vui Lòng Đợi",280,18,-1,5,33,'Tahoma',10,700)
  26.     $spid = Run($sCocCoc,'',@SW_HIDE)
  27.     While ProcessExists($spid)
  28.         ControlClick('','Khởi động trình duyệt cùng hệ thống','ui_Button1')
  29.         ControlClick('Trình cài đặt Cốc Cốc','Cảm ơn bạn đã cài đặt Cốc Cốc. ','Button1')
  30.     WEnd
  31.     If ProcessExists('browser.exe') <> @AutoItPID Then ProcessClose('browser.exe')
  32.     If FileExists($sDir) Then DirRemove($sDir,1)
  33. EndIf
  34.  
  35. Func _InetGetProgress($progressID, $LableSize, $LableSpeed, $sURL, $sDirectory)
  36.     Local $hDownload, $iBytesRead = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sSize
  37.     $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
  38.     If @error Then
  39.         Return SetError(1, 0, $sFilePath)
  40.     EndIf
  41.     $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
  42.     $iFileSize = InetGetSize($sURL, 1)
  43.     $hDownload = InetGet($sURL, $sDirectory, 0, 1)
  44.     If @error Then
  45.         Return SetError(1, 0, $sFilePath)
  46.     EndIf
  47.     $sSpeed = "- Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
  48.         $iTimer = TimerInit()
  49.     While InetGetInfo($hDownload, 2) = 0
  50.         $iBytesRead = InetGetInfo($hDownload, 0)
  51.         $iPercentage = $iBytesRead * 100 / $iFileSize
  52.         $sSize =_ByteSuffix($iBytesRead, 0) & " / " & _ByteSuffix($iFileSize, 0)
  53.         If TimerDiff($iTimer) > 1000 Then
  54.             $sSpeed = "- Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
  55.             $iSpeed = $iBytesRead
  56.             $iTimer = TimerInit()
  57.             GUICtrlSetData($LableSpeed, $sSpeed)
  58.         EndIf
  59.         GUICtrlSetData($progressID,Round($iPercentage, 0))
  60.         GUICtrlSetData($LableSize, $sSize)
  61.         Sleep(200)
  62.     WEnd
  63.     InetClose($hDownload)
  64.     GUICtrlSetData($progressID,100)
  65.     Return $sDirectory
  66. EndFunc
  67.  
  68. Func _ByteSuffix($iBytes, $iRound = 2)
  69.     Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
  70.     While $iBytes > 1023
  71.         $A += 1
  72.         $iBytes /= 1024
  73.     WEnd
  74.     Return Round($iBytes, $iRound) & $aArray[$A]
  75. EndFunc
  76.  
  77. Func _WinAPI_SetLayeredWindowAttributes($hWnd, $iTranscolor, $iTransGUI = 255, $iFlags = 0x03, $bColorRef = False)
  78.     If $iFlags = Default Or $iFlags = "" Or $iFlags < 0 Then $iFlags = 0x03
  79.     If Not $bColorRef Then
  80.         $iTranscolor = Int(BinaryMid($iTranscolor, 3, 1) & BinaryMid($iTranscolor, 2, 1) & BinaryMid($iTranscolor, 1, 1))
  81.     EndIf
  82.     Local $aResult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "INT", $iTranscolor, "byte", $iTransGUI, "dword", $iFlags)
  83.     If @error Then Return SetError(@error, @extended, False)
  84.     Return $aResult[0]
  85. EndFunc
Add Comment
Please, Sign In to add comment