Jump to content
RaiNote

Question IE and Progress

Recommended Posts

RaiNote

Hello everyone,

Question 1: How to attach an IE Download to a Progressbar?

Question 2: How to make an IE Download like a streaming Download(download can be paused and continued every time)?

Question 3: How to do it with my UDF like Code :o?

Question 4: How to do add a Label which shows the released time?

Question 5: How to show how long it takes also the Connection Speed?

Question 6: How to get the Connection Speed to a Server?

#include-once
#include <MsgBoxConstants.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: _Patch
; Description ...: Easy Patch System(unzipping currently not included)
;                  I could need a bit help for this code ^-^.
; Syntax ........: _Patch($DownloadURL, $DownloadPath)
; Parameters ....: $DownloadURL         - URL for the Download.
;                  $DownloadPath        - Where the download file will be installed.
;                  $Title               - Project Name Will be displayed in the MsgBox.
; Return values .: None
; Author ........: RaiNote
; Modified ......: 
; Remarks .......: 
; Related .......: 
; Link ..........: 
; Example .......: No
; ===============================================================================================================================Func _Patch($DownloadURL,$DownloadPath)
Func _Patch($DownloadURL,$DownloadPath,$Title = "Title")
    
$Byte = InetGetSize($DownloadURL,0);Download Size
    
    If $Byte > 1024 Then
        
    $Kilobyte = $Byte / 1024;Converting Byte to Kilobytes
        
        If $Kilobyte > 1024 Then
            
        $Megabyte = $Kilobyte / 1024;Converting Kilobyte to Megabyte
            
            If $Megabyte > 1024 Then
                
            $Gigabyte = $Megabyte / 1024;Converting Megabyte to Gigabyte
            
                If $Gigabyte > 1024 Then
                
                $Terabyte = $Gigabyte / 1024;Converting Gigabyte to Terabyte
                
                    If $Terabyte > 1024 Then
                    
                    $Petabyte = $Terabyte / 1024;Converting Terabyte to Petabyte
                    
                        If $Petabyte > 1024 Then
                            
                            $Exabyte = $Petabyte / 1024;Converting Petabyte to Exabyte
                            $_PATCH_SIZE1 = Round($Exabyte,2) & " EB"
                            
                        ElseIf $Petabyte < 1024 Then
                            
                            $Petabyte = $Terabyte / 1024
                            $_PATCH_SIZE1 = Round($Petabyte,2) & " PB"
                            
                        EndIf
                        
                    ElseIf $Terabyte < 1024 Then
                    
                    $Terabyte = $Gigabyte / 1024
                    $_PATCH_SIZE1 = Round($Terabyte,2) & " TB"
                    
                    EndIf
                
                ElseIf $Gigabyte < 1024 Then
                
                $Gigabyte = $Megabyte / 1024
                $_PATCH_SIZE1 = Round($Gigabyte,2) & " GB"
                
                EndIf
                
            ElseIf $Megabyte < 1024 Then
                
            $Megabyte = $Kilobyte / 1024
            $_PATCH_SIZE1 = Round($Megabyte,2) & " MB"
                
            EndIf
            
        ElseIf $Kilobyte < 1024 Then
            
        $Kilobyte = $Byte / 1024
        $_PATCH_SIZE1 = Round($Kilobyte,2) & " KB"
            
        EndIf
        
    ElseIf $Byte < 1024 Then
    
    $_PATCH_SIZE1 = $Byte & " Bytes"
    
EndIf
    
$_PATCH_INFO = MsgBox(52,$Title,$Title & "needs to be patched. If u want to patch continue" & @CRLF & " if not it will close automaticly.(Size :" & " " & $_PATCH_SIZE1 & ")",0)

switch $_PATCH_INFO

    case 6 ;YES
    
    $_Patch_Download = InetGet($DownloadURL,$DownloadPath,0,0)

    case 7 ;NO
    
    Exit

endswitch
        
EndFunc

RaiNote, not the final answer you're looking for, but you may start by simplifying your math and reducing clutter in the script. Instead of all the If statements (67 lines if I count correctly), you could do something like this (20 lines, not counting comments):

;b = 1
;KB = 1024
;MB = 1,048,576
;GB = 1,073,741,824
;TB = 1,099,511,627,776
;PB = 1,125,899,906,842,624
;EB = 1,152,921,504,606,846,976

$DownloadURL = "https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"
$iReturn = InetGetSize($DownloadURL,0);Download Size

    Select
        Case $iReturn > 1152000000000000000 ;Exabyte
            $FileSize = Round($iReturn / (1024 ^ 6), 2) & "EB"
        Case $iReturn > 1125000000000000
            $FileSize = Round($iReturn / (1024 ^ 5), 2) & "PB"
        Case $iReturn > 1099000000000
            $FileSize = Round($iReturn / (1024 ^ 4), 2) & "TB"
        Case $iReturn > 1073000000
            $FileSize = Round($iReturn / (1024 ^ 3), 2) & "GB"
        Case $iReturn > 1048000
            $FileSize = Round($iReturn / (1024 ^ 2), 2) & "MB"
        Case $iReturn > 1024
            $FileSize = Round($iReturn / 1024, 2) & "KB"
        Case Else
            $FileSize = Round($iReturn) & "Bytes"
    EndSelect



ConsoleWrite($FileSize & @CRLF)

 

​Thx for this :o

I hope someone could help me :3 also how is this UDF with the FileSizeSystem :o

P.S.: Also a cat can get shy.

Edited by RaiNote

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Share this post


Link to post
Share on other sites
JLogan3o13

RaiNote, not the final answer you're looking for, but you may start by simplifying your math and reducing clutter in the script. Instead of all the If statements (67 lines if I count correctly), you could do something like this (20 lines, not counting comments):

;b = 1
;KB = 1024
;MB = 1,048,576
;GB = 1,073,741,824
;TB = 1,099,511,627,776
;PB = 1,125,899,906,842,624
;EB = 1,152,921,504,606,846,976

$DownloadURL = "https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"
$iReturn = InetGetSize($DownloadURL,0);Download Size

    Select
        Case $iReturn > 1152000000000000000 ;Exabyte
            $FileSize = Round($iReturn / (1024 ^ 6), 2) & "EB"
        Case $iReturn > 1125000000000000
            $FileSize = Round($iReturn / (1024 ^ 5), 2) & "PB"
        Case $iReturn > 1099000000000
            $FileSize = Round($iReturn / (1024 ^ 4), 2) & "TB"
        Case $iReturn > 1073000000
            $FileSize = Round($iReturn / (1024 ^ 3), 2) & "GB"
        Case $iReturn > 1048000
            $FileSize = Round($iReturn / (1024 ^ 2), 2) & "MB"
        Case $iReturn > 1024
            $FileSize = Round($iReturn / 1024, 2) & "KB"
        Case Else
            $FileSize = Round($iReturn) & "Bytes"
    EndSelect



ConsoleWrite($FileSize & @CRLF)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
RaiNote

Oh Thanks for this ^-^ but why the Script was so big was caused by liking If Statements :o but your code could anyway help but where is the "Download".part file because this is normally the file which got the current data what is downloaded :o I'm searching since hours for this file. Nah whatever Thank you very much. Also that isn't one question.

 

Edited by RaiNote

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • FMS
      By FMS
      Hello,
      I try to get all the text from a news site around a subject.
      The first run I get all the text inside a attribute in an array.
      When i try to go back and reload another page it chrashes and think it because "$oIE.GoBack"
      I couldn't find anything in the help/forum around this subject.
      Do I need to reload the $oIE or something afther an X.GoBack?
      The error i got is :
      if $oTag2.GetAttribute("class") == "NewsDetail" Then if $oTag2^ ERROR I'm not shure why I got this error, maybe someone could explain?
      Also I'm open for some pointers in this test script because I'm pretty new in working whit the IE.UDF
      Maybe there is an simpler way to get the same results?

      test script:
      #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "Terminate") Global $oIE = _IECreate("https://www.iex.nl/Zoeken/Nieuws.aspx?q=air%20france") ;get first subject Global $oLink1 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl00_linkNews") Sleep(500) _IEAction($oLink1, "click") Sleep(500) Global $oTags = _IETagNameGetCollection($oIE, "div") Global $aResults[1] For $oTag In $oTags if $oTag.GetAttribute("class") == "NewsDetail" Then _ArrayAdd($aResults, $oTag.innerTEXT) EndIf Next $aResults[0] = UBound($aResults) - 1 _ArrayDisplay($aResults, "Episodelist") ConsoleWrite($aResults[1] & @CRLF) $oIE.GoBack ;get second subject Global $oLink2 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl01_linkNews") Sleep(500) _IEAction($oLink2, "click") Sleep(500) Local $oTags2 = _IETagNameGetCollection($oIE, "div") Local $aResults2[1] For $oTag2 In $oTags2 if $oTag2.GetAttribute("class") == "NewsDetail" Then _ArrayAdd($aResults2, $oTag2.innerTEXT) EndIf Next $aResults2[0] = UBound($aResults2) - 1 ConsoleWrite($aResults2[1] & @CRLF) Func Terminate() _IEQuit($oIE) Exit EndFunc ;==>Terminate  
    • nacerbaaziz
      By nacerbaaziz
      Hello
      Can we pause and resume the download in the InetGet function?
      If is possible, what is the solution please?
      I used this code To manage the download

      #include <INet.au3> func _downloader($name, $linc, $filepath, $RTLF = false, $link = false) global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link) global $path = $filePath $labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20) global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20) global $Progress = "" global $sText = ""     For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.         $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case). next global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20) _GUICtrlEdit_SetReadOnly(-1, true) GUIStartGroup("") global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20) GUIStartGroup("") $button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01) $iIndex = 0 global $Target global $url GUIStartGroup("") global $Progress = GUICtrlCreateProgress(50, 90, 150, 20) global $Target = $filepath global $url = $linc global $path = $filepath global $hDownloadNo = _RSMWare_GetData($url, $Target) global $status = false AdlibRegister("SetProgress") global $onprogress = false, $curent = false GUISetState(@sw_Show) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button $asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?") if $asc = 6 then AdlibUnRegister("SetProgress") GUIDelete() If $hDownloadNo <> 0 Then InetClose($hDownloadNo) exitLoop endIf EndSwitch if $status = -1 then $status = 0 $hDownloadNo = _RSMWare_GetData($url, $Target) $onprogress = false $curent = false elseIf $Status = 1 then $status = $path GUIDelete() AdlibUnRegister("SetProgress") exitLoop endIf WEnd return $status endFunc Func _RSMWare_GetData($url, $Target) Local $hDownload = InetGet($url, $Target, 1, 1) Return $hDownload EndFunc ;==>_RSMWare_GetData Func SetProgress() Local $state If $hDownloadNo <> 0 Then $state = InetGetInfo($hDownloadNo) If @error = 0 Then $infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB " $onprogress = Round(Ceiling(($state[0] / $state[1]) * 100)) if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then if $onProgress <= 0 then $onProgress = 0 GUICtrlSetData($Progress, $onProgress) GUICtrlSetData($labelTxt0, $infor) GUICtrlSetData($labelTxt2, $onProgress & "%") if _isChecked($beep) then if $onprogress > $curent then beep((100 + $onprogress * 20), 100) $curent = $onprogress endIf endIf endIf If $state[2] Then If $state[3] Then InetClose($hDownloadNo) $status = 1 else InetClose($hDownloadNo) $status = -1 endIf endIf EndIf endIf EndFunc ;==>SetProgress
    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • VollachR
      By VollachR
      Hi,
      I'd like to show a progress bar for an operation performed by an external program my script is running silently, I want to show it in a GUI I created using the GUICtrlCreateProgress but I have no idea how to do it.
      The important thing to point out is that there's no way of knowing how long the external program will run, as it is a file splitter and it depends on the size of file it splits and the split parts size.
      Can someone point me in the right direction or give me an example how to do so?
      This is my RunWait command:
      RunWait($MYFILES1 & '\fsplit.exe -split ' & $Size & ' mb ' & $File & " -f " & $File & "." & $extension) It uses multiple variables declared and set earlier in the script, how will I got about having the progress of that command shown using GUICtrlCreateProgress ? Is it possible?
      Thank you.
    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
×