Chromium Downloader


SUBMITTED BY: Guest

DATE: May 28, 2013, 5:37 p.m.

FORMAT: Text only

SIZE: 2.8 kB

HITS: 1517

  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <ProgressConstants.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <INet.au3>
  7. #NoTrayIcon
  8. $window = GUICreate("Chromium Downloader", 306, 131, 192, 124)
  9. $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP)
  10. $progressbar = GUICtrlCreateProgress(9, 104, 286, 17)
  11. $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89)
  12. $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17)
  13. $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17)
  14. $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17)
  15. $version = GUICtrlCreateLabel("", 120, 24, 70, 17)
  16. $size = GUICtrlCreateLabel("", 120, 48, 70, 17)
  17. $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17)
  18. GUICtrlCreateGroup("", -99, -99, 1, 1)
  19. GUISetState(@SW_SHOW)
  20. Global $versionURL = "<a href='http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST' class='bbc_url' title='External link' rel='nofollow external'>http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST"</a>
  21. Global $url = ""
  22. Global $filename = "chromium.zip"
  23. Global $versionNum = ""
  24. Global $fileSize = ""
  25. Sleep(200)
  26. setInfo()
  27. While 1
  28. $nMsg = GUIGetMsg()
  29. Switch $nMsg
  30. Case $GUI_EVENT_CLOSE
  31. Exit
  32. Case $download
  33. download()
  34. EndSwitch
  35. WEnd
  36. Func download()
  37. InetGet($url, $filename, 1, 1)
  38. While @InetGetActive
  39. setPercent(@InetGetBytesRead)
  40. $msg = GUIGetMsg()
  41. if $msg = $GUI_EVENT_CLOSE then
  42. InetGet("abort")
  43. FileDelete("chromium.zip")
  44. Exit
  45. EndIf
  46. Sleep(10)
  47. WEnd
  48. EndFunc
  49. Func setInfo()
  50. $versionNum = _INetGetSource($versionURL)
  51. GUICtrlSetData($version, $versionNum)
  52. $url = "<a href='http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/' class='bbc_url' title='External link' rel='nofollow external'>http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/"</a> & $versionNum & "/chrome-win32.zip"
  53. $fileSize = InetGetSize($url)
  54. GUICtrlSetData($size, mbSize($fileSize, 2))
  55. EndFunc
  56. Func mbSize($num, $places)
  57. return Round( (($num / 1024) / 1024), $places ) & " MB"
  58. EndFunc
  59. Func setPercent($currentSize)
  60. $percent = Round( (($currentSize / $fileSize) * 100) ) & "%"
  61. GUICtrlSetData($progressbar, $percent)
  62. GUICtrlSetData($percentDone, $percent)
  63. EndFunc

comments powered by Disqus