Frage zur Progressbar

  • Hoi Leute also ich habe grade den Encypter von AutoIt gefunden ....\AutoIt3\Examples\GUI\Advanced\encrypter .....wenn man jetzt level 10 auswählt und dann einen Satz eingibt dauert es eine weile bis der Encrypter das encryptet hat!!Und das würde ich gerne mit einer Progressbar darstellen leider steht in der Hilfe nur wie man die Progressbar"zeit" selber angibt ,ich brauche es aber so das er herausfindet wie lange er braucht es zu encrypten und das dann eben abbildet wie bei jedem Programm!!!

    Einmal editiert, zuletzt von WOnder (21. November 2010 um 12:24)

  • In die Zukunft sehen geht schlecht ;). Also wirst du wohl Anhand des Fortschritts und der vergangenen Zeit, die verbleibende Zeit berechnen müssen. (Die Dauer ist ja auch Prozessorabhängig).
    Beispiel:

    Verbleibende Zeit bei Progressbar
    [autoit]

    $iFrameDuration = 100

    [/autoit] [autoit][/autoit] [autoit]

    $iProgress = 0
    $iEstimatedDuration = 1000

    [/autoit] [autoit][/autoit] [autoit]

    ProgressOn("Test Progress", "Progress 0%", "Elapsed Time: 00:00 / Remaining Time: -", Default, Default, 18)

    [/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("_Progress", $iFrameDuration)
    $iElapsedTime = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    Edit: Und die Crypt.au3 umschreiben, dass sie dir auch die nötigen Informationen liefert. (Das ist der schwierige Teil, wie AutoBert schon gesagt hat)...

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(100) * $iProgress < 100
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1000)
    ProgressOff()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Progress / ElapsedTime = PPS |* ElapsedTime
    ;Progress = PPS * ElapsedTime |/ PPS
    ;Progress / PPS = ElapsedTime
    ;EstimatedDuration(ElapsedTime for 100%) = 100(ProcessCompleted) / PPS

    [/autoit] [autoit][/autoit] [autoit]

    Func _Progress()
    If $iProgress = 100 Then Return
    $iProgress += 1
    If TimerDiff($iElapsedTime) > 500 And $iProgress > 0 Then
    $iEstimatedDuration = 100 / ($iProgress / TimerDiff($iElapsedTime))
    EndIf
    ProgressSet($iProgress, "Elapsed Time: " & Round(TimerDiff($iElapsedTime) / 60000) & ":" & Round(TimerDiff($iElapsedTime) / 1000) & " / Remaining Time: " & Round(($iEstimatedDuration - TimerDiff($iElapsedTime)) / 60000 ) & ":" & Round(($iEstimatedDuration - TimerDiff($iElapsedTime)) / 1000 ), "Progress: " & $iProgress)
    EndFunc

    [/autoit]


    Du musst dann nur den Fortschritt in Prozent berechnen (VerarbeiteteZeichen/Gesamtzeichen*100) und dann müsste es gehen...

  • Hallo WOnder,

    dann musst du dir die Crypt.au3 umschreiben, denn es geht mit dieser nicht was du möchtest. Vielleicht machst du ja deinem Namen Ehre und schaffst es,

    mfg autoBert

  • Vorallem musst du dafür wohl eine eigene encrypt Funktion schreiben. Dazu schaust du am besten in C:\Program Files (x86)\AutoIt3\Include\string.au3 die Funktion _StringEncrypt an.
    Wenn du eine überarbeitete Version der Funktion in dein Script einfügst kannst du dort in den Schleifen auch deine Progressbar fortschreiten lassen. Wenn du zusätzlich zu den Prozentwerten auch eine Zeitabschätzung haben willst, siehe das Posting von name22.

    Darfst das dann gerne auch hier posten falls du das hinbekommst. ;)

    EDIT:

    Hier mal das modifizierte example mit angepasster StringEncrypt Funktion. Allerdings ist das so noch sehr ungenau, da die einzelnen Durchgänge der äusseren Schleife unterschiedlich lang benötigen. Ausserdem werden nur recht wenig Werte ermittelt abhängig vom level. Um das ganze exakter und gleichmässiger zu gestalten müsste man den Progress auch in den inneren Schleifen aktualisieren. Sinnvoll wäre es wohl das ganze über eine separate progress Funktion zu machen, die jeweils in den Schleifen aufgerufen wird. Ich denke aber das sollte dir erstmal reichen um das Prinzip zu verstehen.

    Spoiler anzeigen
    [autoit]


    ;====================================================
    ;============= Encryption Tool With GUI =============
    ;====================================================
    ; AutoIt version: 3.0.103
    ; Language: English
    ; Author: "Wolvereness"
    ;
    ; ----------------------------------------------------------------------------
    ; Script Start
    ; ----------------------------------------------------------------------------
    #include <GUIConstantsEx.au3>
    ;#include <String.au3> ; entfernt da nicht mehr benötigt...
    ;#include files for encryption and GUI constants

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)
    Global $progressbar ; neu
    _Main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _Main()
    Local $WinMain, $EditText, $InputLevel, $InputPass, $UpDownLevel
    Local $EncryptButton, $DecryptButton, $string

    [/autoit] [autoit][/autoit] [autoit]

    #forceref $UpDownLevel
    ;~~
    $WinMain = GUICreate('Encryption tool', 400, 500) ; größe geändert
    ; Creates window
    ;~~
    $EditText = GUICtrlCreateEdit('', 5, 5, 380, 350)
    ; Creates main edit
    ;~~
    $InputPass = GUICtrlCreateInput('', 5, 360, 100, 20, 0x21)
    ; Creates the password box with blured/centered input
    ;~~
    $InputLevel = GUICtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
    $UpDownLevel = GUICtrlSetLimit(GUICtrlCreateUpdown($InputLevel), 10, 1)
    ; These two make the level input with the Up|Down ability
    ;~~
    $EncryptButton = GUICtrlCreateButton('Encrypt', 170, 360, 105, 35)
    $DecryptButton = GUICtrlCreateButton('Decrypt', 285, 360, 105, 35)
    $progressbar = GUICtrlCreateProgress(20,450,360,25) ; neu
    ; Encryption/Decryption buttons
    ;~~
    GUICtrlCreateLabel('Password', 5, 385)
    GUICtrlCreateLabel('Level', 110, 385)
    ; Simple text labels so you know what is what
    ;~~
    GUISetState()
    ; Shows window
    ;~~

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $EncryptButton
    ; When you press Encrypt
    ;~~
    GUISetState(@SW_DISABLE, $WinMain)
    ; Stops you from changing anything
    ;~~
    $string = GUICtrlRead($EditText)
    ; Saves the editbox for later
    ;~~
    GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.')
    ; Friendly message
    ;~~
    GUICtrlSetData($progressbar,0) ; neu
    GUICtrlSetData($EditText, _StringEncrypt2(1, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))
    ; Calls the encryption. Sets the data of editbox with the encrypted string
    ;~~
    GUISetState(@SW_ENABLE, $WinMain)
    ; This turns the window back on
    ;~~
    Case $DecryptButton
    ; When you press Decrypt
    ;~~
    GUISetState(@SW_DISABLE, $WinMain)
    ; Stops you from changing anything
    ;~~
    $string = GUICtrlRead($EditText)
    ; Saves the editbox for later
    ;~~
    GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.')
    ; Friendly message
    ;~~
    GUICtrlSetData($progressbar,0) ; neu
    GUICtrlSetData($EditText, _StringEncrypt2(0, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))
    ; Calls the encryption. Sets the data of editbox with the encrypted string
    ;~~
    GUISetState(@SW_ENABLE, $WinMain)
    ; This turns the window back on
    ;~~
    EndSwitch
    WEnd
    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _StringEncrypt2
    ; Description ...: An RC4 based string encryption function.
    ; Syntax.........: _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword[, $i_EncryptLevel = 1])
    ; Parameters ....: $i_Encrypt - 1 to encrypt, 0 to decrypt.
    ; $s_EncryptText - Text to encrypt/decrypt.
    ; $s_EncryptPassword - Password to encrypt/decrypt with.
    ; $i_EncryptLevel - Optional: Level to encrypt/decrypt. Default = 1
    ; Return values .: Success - The Encrypted/Decrypted string.
    ; Failure - Blank string and @error = 1
    ; Author ........: Wes Wolfe-Wolvereness <Weswolf at aol dot com>
    ; Modified.......: by misterspeed
    ; Remarks .......: WARNING: This function has an extreme timespan if the encryption level or encrypted string are too large!
    ; Related .......:
    ; Link ..........:
    ; Example .......: Yes
    ; ===============================================================================================================================
    Func _StringEncrypt2($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
    SetError(1, 0, '')
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
    SetError(1, 0, '')
    Else
    If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1
    Local $v_EncryptModified
    Local $i_EncryptCountH
    Local $i_EncryptCountG
    Local $v_EncryptSwap
    Local $av_EncryptBox[256][2]
    Local $i_EncryptCountA
    Local $i_EncryptCountB
    Local $i_EncryptCountC
    Local $i_EncryptCountD
    Local $i_EncryptCountE
    Local $v_EncryptCipher
    Local $v_EncryptCipherBy
    Local $counter = 0 ; neu
    If $i_Encrypt = 1 Then
    For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
    $i_EncryptCountG = ''
    $i_EncryptCountH = ''
    $v_EncryptModified = ''
    For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
    $i_EncryptCountH = 1
    Else
    $i_EncryptCountH += 1
    EndIf
    $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
    Next
    $s_EncryptText = $v_EncryptModified
    $i_EncryptCountA = ''
    $i_EncryptCountB = 0
    $i_EncryptCountC = ''
    $i_EncryptCountD = ''
    $i_EncryptCountE = ''
    $v_EncryptCipherBy = ''
    $v_EncryptCipher = ''
    $v_EncryptSwap = ''
    $av_EncryptBox = ''
    Local $av_EncryptBox[256][2]
    For $i_EncryptCountA = 0 To 255
    $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
    $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
    Next
    For $i_EncryptCountA = 0 To 255
    $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
    $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
    $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
    $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
    Next
    For $i_EncryptCountA = 1 To StringLen($s_EncryptText)
    $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
    $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
    $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]
    $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
    $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)
    Next
    $s_EncryptText = $v_EncryptCipher
    $counter = $counter + 1 ; neu
    GUICtrlSetData($progressbar,100*($counter/($i_EncryptLevel+1))) ; neu
    Next
    Else
    For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
    $i_EncryptCountB = 0
    $i_EncryptCountC = ''
    $i_EncryptCountD = ''
    $i_EncryptCountE = ''
    $v_EncryptCipherBy = ''
    $v_EncryptCipher = ''
    $v_EncryptSwap = ''
    $av_EncryptBox = ''
    Local $av_EncryptBox[256][2]
    For $i_EncryptCountA = 0 To 255
    $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
    $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
    Next
    For $i_EncryptCountA = 0 To 255
    $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
    $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
    $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
    $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
    Next
    For $i_EncryptCountA = 1 To StringLen($s_EncryptText) Step 2
    $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
    $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
    $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]
    $v_EncryptCipherBy = BitXOR(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE)
    $v_EncryptCipher = $v_EncryptCipher & Chr($v_EncryptCipherBy)
    Next
    $s_EncryptText = $v_EncryptCipher
    $i_EncryptCountG = ''
    $i_EncryptCountH = ''
    $v_EncryptModified = ''
    For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
    $i_EncryptCountH = 1
    Else
    $i_EncryptCountH += 1
    EndIf
    $v_EncryptModified &= Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
    Next
    $s_EncryptText = $v_EncryptModified
    $counter = $counter + 1 ; neu
    GUICtrlSetData($progressbar,100*($counter/($i_EncryptLevel+1))) ; neu
    Next
    EndIf
    Return $s_EncryptText
    EndIf
    EndFunc ;==>_StringEncrypt

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    2 Mal editiert, zuletzt von misterspeed (21. November 2010 um 04:11)

  • Ok ich habe die Crypt.au3 in etwa so umgeschrieben wie misterspeed es hat , funzt einawandfrei danke leuts!!!