Jump to content

Progress bar to show how long you are in a txt file


Recommended Posts

#include <ColorConstants.au3>; Including required files
#include <GUIConstantsEx.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>
Example()

Func Example()
    Local $hash
    Local $hashes = "hash.txt"
    _FileReadToArray($hashes, $hash)
    For $i = 1 To UBound($hash) - 500
        $hashcheck = $hash[$i]
        $PDenc = "hash=" & $hashcheck & "&decrypt=Decrypt"
        $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
        $oHTTP.Open("POST", "http://myurl/", False) ; Post url
        $oHTTP.SetRequestHeader("Host", "myurl")
        $oHTTP.SetRequestHeader("Connection", "keep-aliveContent-Length: 29")
        $oHTTP.SetRequestHeader("Cache-Control", "max-age=0")
        $oHTTP.SetRequestHeader("Origin", "http://myurl")
        $oHTTP.SetRequestHeader("Upgrade-Insecure-Requests", "1")
        $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36")
        $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
        $oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
        $oHTTP.SetRequestHeader("Referer", "http://myurl")
        $oHTTP.SetRequestHeader("Accept-Language", "en-US,en;q=0.8")
        $oHTTP.Send($PDenc)
        $oReceived = $oHTTP.ResponseText
        $oStatusCode = $oHTTP.Status
        sleep(2000)
        If $oStatusCode = 503 then
        MsgBox(4096, "Response code", $oStatusCode)
        ExitLoop
        EndIf
        ; Saves the body response regardless of the Response code
        $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
        FileWrite($file, $oReceived)
        $read = FileRead("Received.html") ;read file
        if StringInStr($read, "not found") Then
ContinueLoop
        Else
            ContinueLoop
        $Datastring = ('</script></div><br/>')
        $newreadamount = _StringBetween($read, $Datastring, "</b><br/><br/>") ;read title from file
        $newreadamount[0] = StringReplace($newreadamount[0], '<b>', "") ; taking out the X makes it easier to compare value
        If @error Then
            ContinueLoop
            EndIf
        $file = FileOpen("decrypted.txt", 1)
        FileWrite($file, $newreadamount[0] & @CRLF)
EndIf
        Next
sleep(2000)
EndFunc   ;==>Example

As you can read my script loads 500 lines of text, lets say I have a list with 10.000 lines
Is there a way to show a progressbar GUI to show how long in a text file I am?
I may not know how long a particular .txt file is always so I am thinking I need some sort of algorythm?
Thanks in advance.

( I just got unclear if I actually read 500 lines each attempt or if I start with 500 and add 1 to it each time? )
 

For $i = 1 To UBound($hash) - 500

; LIke that ^
For $i = 500 To UBound($hash) - 500
; or like this^

Thanks a lot.

Link to comment
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
 Share

×
×
  • Create New...