Jump to content
Sign in to follow this  

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>

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")
        $oReceived = $oHTTP.ResponseText
        $oStatusCode = $oHTTP.Status
        If $oStatusCode = 503 then
        MsgBox(4096, "Response code", $oStatusCode)
        ; 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
        $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
        $file = FileOpen("decrypted.txt", 1)
        FileWrite($file, $newreadamount[0] & @CRLF)
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.

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
Sign in to follow this  

  • Similar Content

    • rm4453
      By rm4453
      I am currently writing a program that parses a massive table from a website, and need a way to add a progress bar while parsing.
      I am currently using the function _IETableWriteToArray($oObj, True) to parse the array. I need the progress bar to update as the table is parsed, not just at the end of the parsing.
      Any help at all would be very much appreciated!
      *EDIT --> The array I am left with after parsing is $array[0-50000][16]
    • VollachR
      By VollachR
      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.
    • Trisha
      By Trisha
      I Have clicked on save as option to save a file, while doing that I need to rename a file appending with sysdate. I have searched in google find the below one line of code:
      FileMove("C:\somefile.txt", "C:\somefile1.txt"), When I am trying to append with sysdate. It is not happening. Please help me out  with the small issue.
    • kneze
      By kneze
      i use from Command Line net user /Domain UserID >> C:\temp\sample.txt to request informations about specific Domain User. Now i wil get Password last set, Password expires, password changeable and all Groups from Global Group Membership of this User to display in a MsgBox. With FUNC _readGroups i can check which position is group date of last password set but i don't know how to get needed informations as i wrote at the beginning.
      Thanks in advance for any hint how can i solve it.
      #cs ---------------------------------------------------------------------------- AutoIt Version: Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <File.au3> $FilePath=@ScriptDir &"\sample.txt" $StringToSearch="Password last set" $CaseSense=0 $Lines=_FileCountLines($FilePath) $hFile=FileOpen($FilePath,0) $LinesCount=_FileCountLines($FilePath) For $i=0 To Number($Lines) $Test=FileReadLine($hFile,$i) If StringInStr($Test,$StringToSearch,$CaseSense) Then $foundLine = $i _readGroups($foundLine,$LinesCount,$i) ;MsgBox(0,"","The string " & $StringToSearch & " was found on line " & $i) ;MsgBox(0,"","Lines found: " & $LinesCount) ExitLoop EndIf Next FileClose($hFile) FUNC _readGroups($foundLine,$LinesCount,$i) ;For $j=$foundLine To Number($LinesCount) $lLine=FileReadLine($hFile,$i) ;$split = StringSplit($lLine," ") $split = StringSplit(StringStripWS($lLine,1)," ") For $x = 1 To $split[0] MsgBox(0,$x,$split[$x]) Next ;MsgBox(0,"",$split[15]& " " & $split[16]) ;Next EndFunc  
    • lewisg
      By lewisg
      Suddenly a RunWait command has stop working after 2 years of no errors, issues, or problems. The code uses RunWait to start Plink.exe, a command-line remote connection tool similar to UNIX ssh. I'm using it to ssh to a linux (Centos) machine, run a Perl script, and redirect the output to a file on a PC running the AutoIt script.  
      $FilePath = "C:\AutoIT\LED" $FilePathPlus = $FilePath & "\plink.exe" $Code1 = RunWait(@ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console The ConsoleWrite output when cut-n-pasted into a DOS box produces the expected file so I know it works. I've also tried many variations of the function moving, adding, and changing the " and ' (quote) marks. Also tried it without the @ComSpec macro and other related functions...e.g.  ShellExecuteWait , etc.
      The PC is a Windows 10 64bit and AutoIT is version
      Searching here and Google has not yielded any clues that helped.