Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin
- Dim $sURL = 'http://files.coccoc.vn/browser/coccoc_vi.exe',$sDir = @TempDir & '\CocCoc_Setup\', $Form1,$Progress1,$sSpeed,$sSize,$spid
- If FileExists($sDir) Then DirRemove($sDir,1)
- DirCreate($sDir)
- $Form1 = GUICreate("", 440, 40, -1, 10, BitOR(0x00800000,0x80000000), BitOR(0x00000008,0x00000080))
- _WinAPI_SetLayeredWindowAttributes($Form1, 0xABCDEF, 255)
- $Progress1 = GUICtrlCreateProgress(5, 20, 430, 17)
- DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Progress1), "wstr", 0, "wstr", 0)
- GUICtrlSetStyle($Progress1, 0x01)
- GUICtrlSetFont(-1, 8, 700,0, "Tahoma")
- $sSize = GUICtrlCreateLabel("0 Kb", 170, 22,130,15,0x0001)
- GUICtrlSetBkColor(-1, -2)
- GUICtrlSetFont(-1, 8, 700,0, "Tahoma")
- GUICtrlCreateLabel("Đang Tải Trình Duyệt Côc Cốc", 55, 1,200,18)
- GUICtrlSetFont(-1, 10, 700,0, "Tahoma")
- $sSpeed = GUICtrlCreateLabel("", 255, 1,170,18)
- GUICtrlSetFont(-1, 10, 700,0, "Tahoma")
- GUISetState(@SW_SHOW)
- Local $sCocCoc =_InetGetProgress($Progress1, $sSize, $sSpeed, $sURL, $sDir)
- If Not @error Then
- MsgBox(064 ,"Thông báo","Tải thành công, chuẩn bị cài đặt"&@CRLF& $sCocCoc,0.5)
- GUIDelete($Form1)
- If Not FileExists($sCocCoc) Then Exit MsgBox(16,'Lỗi - Không tìm thấy file cài đặt', _
- 'Có lỗi trong quá trình tải file, vui lòng thử lại',3)
- SplashTextOn('',"Đang cài đặt Cốc Cốc, Vui Lòng Đợi",280,18,-1,5,33,'Tahoma',10,700)
- $spid = Run($sCocCoc,'',@SW_HIDE)
- While ProcessExists($spid)
- ControlClick('','Khởi động trình duyệt cùng hệ thống','ui_Button1')
- ControlClick('Trình cài đặt Cốc Cốc','Cảm ơn bạn đã cài đặt Cốc Cốc. ','Button1')
- WEnd
- If ProcessExists('browser.exe') <> @AutoItPID Then ProcessClose('browser.exe')
- If FileExists($sDir) Then DirRemove($sDir,1)
- EndIf
- Func _InetGetProgress($progressID, $LableSize, $LableSpeed, $sURL, $sDirectory)
- Local $hDownload, $iBytesRead = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sSize
- $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
- If @error Then
- Return SetError(1, 0, $sFilePath)
- EndIf
- $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
- $iFileSize = InetGetSize($sURL, 1)
- $hDownload = InetGet($sURL, $sDirectory, 0, 1)
- If @error Then
- Return SetError(1, 0, $sFilePath)
- EndIf
- $sSpeed = "- Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
- $iTimer = TimerInit()
- While InetGetInfo($hDownload, 2) = 0
- $iBytesRead = InetGetInfo($hDownload, 0)
- $iPercentage = $iBytesRead * 100 / $iFileSize
- $sSize =_ByteSuffix($iBytesRead, 0) & " / " & _ByteSuffix($iFileSize, 0)
- If TimerDiff($iTimer) > 1000 Then
- $sSpeed = "- Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
- $iSpeed = $iBytesRead
- $iTimer = TimerInit()
- GUICtrlSetData($LableSpeed, $sSpeed)
- EndIf
- GUICtrlSetData($progressID,Round($iPercentage, 0))
- GUICtrlSetData($LableSize, $sSize)
- Sleep(200)
- WEnd
- InetClose($hDownload)
- GUICtrlSetData($progressID,100)
- Return $sDirectory
- EndFunc
- Func _ByteSuffix($iBytes, $iRound = 2)
- Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
- While $iBytes > 1023
- $A += 1
- $iBytes /= 1024
- WEnd
- Return Round($iBytes, $iRound) & $aArray[$A]
- EndFunc
- Func _WinAPI_SetLayeredWindowAttributes($hWnd, $iTranscolor, $iTransGUI = 255, $iFlags = 0x03, $bColorRef = False)
- If $iFlags = Default Or $iFlags = "" Or $iFlags < 0 Then $iFlags = 0x03
- If Not $bColorRef Then
- $iTranscolor = Int(BinaryMid($iTranscolor, 3, 1) & BinaryMid($iTranscolor, 2, 1) & BinaryMid($iTranscolor, 1, 1))
- EndIf
- Local $aResult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "INT", $iTranscolor, "byte", $iTransGUI, "dword", $iFlags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aResult[0]
- EndFunc
Add Comment
Please, Sign In to add comment