Jump to content
Sign in to follow this  
RyukShini

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

Recommended Posts

RyukShini
#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.

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

    • Trisha
      By Trisha
      Hello,
      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
      hi
      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: 3.3.14.3 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  
      sample.txt
    • 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 ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /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 3.3.14.2.
      Searching here and Google has not yielded any clues that helped. 
    • BrewManNH
      By BrewManNH
      I have created a UDF that will allow you to easily create a customizable GUI with either a standard progress bar or a marquee style progress bar. You can change the size and back ground color of the GUI, as well as the font, font size, and color of the text. The function doesn't require any parameters to operate, but the default text is very generic so you probably would want to set that at the very least.
    • nacerbaaziz
      By nacerbaaziz
      hello
      please i need to link a progress bar with a time can you help me?
      e.g
      i want to set a progress bar for 10 sec
      am waiting for your answers
      thank you.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.