Jump to content

Recommended Posts

Posted

Hi,

I have made a script which runs md5deep on a selected file in Total Commander. Works nice only have one cosmetic problem. Here is the script :

#include <GUIConstants.au3>
#include <Constants.au3>

;Autoit Options
AutoItSetOption ( "TrayIconHide", 1 )

;Variables
$inputpst = ""
$inputpst2 = ""
$varfile = ""
$varmd5 = ""

;Creating GUI
GUICreate ( "Calculating MD5", 320, 105, -1, -1, $WS_BORDER )
GUISetState ( @SW_SHOW )

;Creating labels
$label = GUICtrlCreateLabel ( "MD5 Hash Code : ",5 ,5 ,200 )

;Creating action button
$button1 = GUICtrlCreateButton ( "Calculate" ,5 ,50 ,60 )
$button2 = GUICtrlCreateButton ( "Compare" ,135, 50, 60 )
$button3 = GUICtrlCreateButton ( "Exit" ,250 ,50, 60 )

;Displaying GUI until it is closed.
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $button3
            ExitLoop
            
        Case $msg = $button1 
            WinSetTitle ( "Calculating MD5", "", "Calculating Hashes please wait... " )
            $varfile = Run ( @ScriptDir & "\md5deep.exe " & $CmdLineRaw, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        ;$varfile = Run ( @ScriptDir & "\md5deep.exe " & "c:\windows\notepad.exe", '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            $varmd5 = StringUpper (StringLeft (StdoutRead($varfile), 32))
            WinSetTitle ( "Calculating Hashes please wait... ", "", "Calculating MD5" )
            GUICtrlCreateLabel ( "MD5 Hash Code : " & $varmd5 ,5 ,5 ,310 )
            GUICtrlCreateLabel ( "Original MD5 : ", 5, 25, 70 )
            $inputpst = GUICtrlCreateInput ( "Paste MD5 hash here..." ,90 ,25 ,215 )
        Case $msg = $button2
            $inputpst2 = GUICtrlRead ( $inputpst )
        ;If $inputpst2 = "" or "Paste MD5 hash here..." Then
        ;   MsgBox ( 0, "Result", "Nothing to compare." )
        ;Else   
                If $varmd5 = $inputpst2 Then
                    MsgBox ( 0, "Result", "Hashes match." )
                Else
                    MsgBox ( 0, "Result", "Hashes do not match." )
                EndIf
        ;EndIf
    EndSelect
Wend

The problem is in the last section :

Case $msg = $button2
            $inputpst2 = GUICtrlRead ( $inputpst )
        ;If $inputpst2 = "" or "Paste MD5 hash here..." Then
        ;   MsgBox ( 0, "Result", "Nothing to compare." )
        ;Else   
                If $varmd5 = $inputpst2 Then
                    MsgBox ( 0, "Result", "Hashes match." )
                Else
                    MsgBox ( 0, "Result", "Hashes do not match." )
                EndIf
        ;EndIf

If the input field is empty or Paste MD5 hash here... is filled and you press button2 it has to come with the MsgBox ( 0, "Result", "Nothing to compare." ). This works but it doesn't go to If $varmd5 = $inputpst2 Then. It doesn't do a hash check. It stay's in a loop with MsgBox ( 0, "Result", "Nothing to compare." ). For testing you could uncomment ;$varfile = Run ( @ScriptDir & "\md5deep.exe " & "c:\windows\notepad.exe", '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD). I have also used Select and case but no result. What I'm a doing wrong ?

Grtz John

Posted (edited)

What the $inputpst? InputControl id or just variable? Show the full script.

And attach the md5deep.exe

Edited by rasim
Posted

What the $inputpst? InputControl id or just variable? Show the full script.

And attach the md5deep.exe

This is the full script.

$inputpst = GUICtrlCreateInput ( "Paste MD5 hash here..." ,90 ,25 ,215 )

Posted

If the input field is empty or Paste MD5 hash here... is filled and you press button2 it has to come with the MsgBox ( 0, "Result", "Nothing to compare." ). This works but it doesn't go to If $varmd5 = $inputpst2 Then. It doesn't do a hash check. It stay's in a loop with MsgBox ( 0, "Result", "Nothing to compare." ).

I don't get the logic in your dismay.

If the input is wrong and there is "nothing to compare", why should it proceed to compare?

"be smart, drink your wine"

Posted

This?

#include <GUIConstants.au3>
#include <Constants.au3>

;Autoit Options
AutoItSetOption ( "TrayIconHide", 1 )

;Variables
$inputpst = ""
$inputpst2 = ""
$varfile = ""
$varmd5 = ""

;Creating GUI
GUICreate ( "Calculating MD5", 320, 105, -1, -1, $WS_BORDER )
GUISetState ( @SW_SHOW )

;Creating labels
$label = GUICtrlCreateLabel ( "MD5 Hash Code : ",5 ,5 ,200 )

;Creating action button
$button1 = GUICtrlCreateButton ( "Calculate" ,5 ,50 ,60 )
$button2 = GUICtrlCreateButton ( "Compare" ,135, 50, 60 )
$button3 = GUICtrlCreateButton ( "Exit" ,250 ,50, 60 )

;Displaying GUI until it is closed.
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $button3
            ExitLoop
        Case $msg = $button1
            WinSetTitle ( "Calculating MD5", "", "Calculating Hashes please wait... " )
            $varfile = Run ( @ScriptDir & "\md5deep.exe " & "c:\windows\notepad.exe", '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ;ConsoleWrite(StdoutRead($varfile))
            $varmd5 = StringLeft(StdoutRead($varfile), 32)
            WinSetTitle ( "Calculating Hashes please wait... ", "", "Calculating MD5" )
            GUICtrlCreateLabel ( "MD5 Hash Code : " & $varmd5 ,5 ,5 ,310 )
            GUICtrlCreateLabel ( "Original MD5 : ", 5, 25, 70 )
            $inputpst = GUICtrlCreateInput ( "Paste MD5 hash here..." ,90 ,25 ,215 )
        Case $msg = $button2
            $inputpst2 = GUICtrlRead ($inputpst)
            If ($inputpst2 = "") Or ($inputpst2 = "Paste MD5 hash here...") Then
                MsgBox ( 0, "Result", "Nothing to compare." )
            ElseIf $varmd5 = $inputpst2 Then
                MsgBox ( 0, "Result", "Hashes match." )
            Else
                MsgBox ( 0, "Result", "Hashes do not match." )
            EndIf
        EndSelect
    Wend

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
×
×
  • Create New...