Jump to content

abberration

Active Members
  • Posts

    557
  • Joined

  • Last visited

2 Followers

Recent Profile Visitors

4,315 profile views

abberration's Achievements

  1. I never had a need to input a tab into an InputBox or any sort of input, but the GuiCtrlCreateInput has a forced "$WS_TABSTOP" control style, which doesn't seem to be able to be disabled and I think is for using tab to shift focus to the next Gui item in the script. I imagine the InputBox has a similar limitation. Both of these do accept the "@tab" macro if you send it to the control through a variable. But none of this helps if you want a way to manually type characters and tabs with your hands. Maybe someone better acquainted with this language might have a solution...
  2. I was wrong about needing a double loop. I made something that I think will work for you, but I did not test the final code because I don't have your folders on my computer. Here is an example script that simply shows an install number incremented with numbers and letters (keep pressing the Backup Guitar Rig button to see the variable changes): #include <ButtonConstants.au3> #include <AutoItConstants.au3> #include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $Form1 = GUICreate("Guitar Rig Backup", 266, 111) Global $Button1 = GUICtrlCreateButton("Backup Guitar Rig", 64, 24, 131, 49, $WS_GROUP) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $sInstallVersion = IniRead("GuitarRigVersion.ini", "Version", "Value", "Install_1a") Local $aString = StringSplit($sInstallVersion, "") Local $sLetter = $aString[$aString[0]] ; this chooses the last character of the string Local $iNum = $aString[$aString[0] - 1] ; this chooses the second to the last character of the string If Asc($sLetter) < 122 Then ; 97 to 122 are ascii characters a-z $sLetter = Chr(Asc($sLetter) + 1) ElseIf Asc($sLetter) = 122 Then ; if it goes beyond the letter z, increment number and reset to letter a $iNum = Chr(Asc($iNum) + 1) $sLetter = Chr(97) EndIf IniWrite("GuitarRigVersion.ini", "Version", "Value", "Install_" & $iNum & $sLetter) Sleep(100) ; added this because I have had fast CPUs run faster than the hard drive can write this data Local $sInstallVersion = IniRead("GuitarRigVersion.ini", "Version", "Value", "Install_1a") MsgBox(0, "", $sInstallVersion) EndSwitch WEnd And here it is integrated with your code (you may have to debug it): #include <ButtonConstants.au3> #include <AutoItConstants.au3> #include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Global $sInstallVersion Local $sSrcCFPath = "C:\Program Files\Common Files\Native Instruments" Local $sSrcPFFolderPath = "C:\Program Files\Native Instruments" Local $sSrcADFolderPath = "C:\Users\Dell\AppData\Local\Native Instruments" Local $sSrcTXTFolderPath = "E:\Text\Native Instruments" Global $Form1 = GUICreate("Guitar Rig Backup", 266, 111) Global $Button1 = GUICtrlCreateButton("Backup Guitar Rig", 64, 24, 131, 49, $WS_GROUP) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $sInstallVersion = IniRead("GuitarRigVersion.ini", "Version", "Value", "Install_1a") Local $aString = StringSplit($sInstallVersion, "") Local $sLetter = $aString[$aString[0]] ; this chooses the last character of the string Local $iNum = $aString[$aString[0] - 1] ; this chooses the second to the last character of the string If Asc($sLetter) < 122 Then $sLetter = Chr(Asc($sLetter) + 1) ElseIf Asc($sLetter) = 122 Then $iNum = Chr(Asc($iNum) + 1) $sLetter = Chr(97) EndIf IniWrite("GuitarRigVersion.ini", "Version", "Value", "Install_" & $iNum & $sLetter) Sleep(100) ; added this because I have had fast CPUs run faster than the hard drive can write this data Local $sInstallVersion = IniRead("GuitarRigVersion.ini", "Version", "Value", "Install_1a") _Create_Dir($sInstallVersion) EndSwitch WEnd ;------------------------------------------------ Func _Create_Dir($MyPath) SplashTextOn("NOTICE!!", "Copying Guitar Rig 5 source data...", 350, 50, -1, -1) Sleep(1000) ;------------------ DirCopy($sSrcCFPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Program Files\Common Files\Native Instruments", $FC_OVERWRITE) DirCopy($sSrcPFFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Program Files\Native Instruments" , $FC_OVERWRITE) DirCopy($sSrcADFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Users\Dell\AppData\Local\Native Instruments", $FC_OVERWRITE) DirCopy($sSrcTXTFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_E\Text\Native Instruments", $FC_OVERWRITE) ;~ ;------------------ SplashTextOn("NOTICE!!", "Copying Guitar Rig 5 data source completed...", 350, 50, -1, -1) Sleep(1000) EndFunc ;==>_Create_Dir
  3. If it were me, I would use the date/time as the variable. It always changes and you know exactly when it was backed up. If you want to use a folder path like "Install_1a" and increment it to "Install_1b", to "Install_1z", then "Install_2a" to "Install_2z", that can be done with reading/writing an ini file, a double loop, and some fancy StringSplit and Chr(num) incremental stuff. Here's the date idea I mentioned (file/folder names cannot use slashes or colons, so I only used dashes and underscores): ;----------------------------------------------- #include <AutoItConstants.au3> #include <FileConstants.au3> ;----------------------------------------------- Opt("MustDeclareVars", 1) ;------------------------------------------------ ;Local $MyPath = '' ; Not necessary because local can be decalred in the function ;------------------ Local $sSrcCFPath = "C:\Program Files\Common Files\Native Instruments" ;------------------ Local $sSrcPFFolderPath = "C:\Program Files\Native Instruments" ;------------------ Local $sSrcADFolderPath = "C:\Users\Dell\AppData\Local\Native Instruments" ;------------------ Local $sSrcTXTFolderPath = "E:\Text\Native Instruments" ;------------------------------------------------ _Create_Dir() ;------------------------------------------------ Func _Create_Dir() Local $MyPath = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "-" & @MIN ;~ MsgBox(0, "", $MyPath) ;------------------ SplashTextOn("NOTICE!!", "Copying Guitar Rig 5 source data...", 350, 50, -1, -1) Sleep(1000) ;------------------ ;~ DirCopy($sSrcCFPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Program Files\Common Files\Native Instruments", $FC_OVERWRITE) ;~ DirCopy($sSrcPFFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Program Files\Native Instruments" , $FC_OVERWRITE) ;~ DirCopy($sSrcADFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_C\Users\Dell\AppData\Local\Native Instruments", $FC_OVERWRITE) ;~ DirCopy($sSrcTXTFolderPath, "I:\Guitar_Rig\Installations\" & $MyPath & "\Data\Source_Data_E\Text\Native Instruments", $FC_OVERWRITE) ;------------------ SplashTextOn("NOTICE!!", "Copying Guitar Rig 5 data source completed...", 350, 50, -1, -1) Sleep(1000) EndFunc ;==>_Create_Dir ;------------------------------------------------
  4. Hi, cramaboule, I don't know if a 64 bit version of the dll is available, but it is possible to use the 32 bit dll with 64 bit operating systems. Simply compile your script as a x86 version and it should work. I use this UDF and even made a huge note at the top of my script reminding me to compile it as x86 for it to work. I have stumbled upon this problem with a couple other .dlls in the past. Another note, I separated my scripts into a main script and one that just does the printing, so I don't have to worry about compiling my main script as 32 bit. My main script does all the Gui and text stuff and then I send the data off to a "PrintPage.exe" that is 32 bit. Basically, I just write the data to an .ini file and have the printing executable read the data.
  5. I think this has to do with #RequireAdmin, which will run the script as an administrator. Try creating the Sageset configuration the exact same way that you run the command. I have created a small example where you can create the command and run it exactly the same way. Maybe it will help? (oh, I prefer shellexecute over run). #RequireAdmin #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 270, 179) $Label1 = GUICtrlCreateLabel("Pick a task:", 16, 16, 60, 17) $Radio1 = GUICtrlCreateRadio("Set Sageset task", 16, 40, 113, 17) $Label2 = GUICtrlCreateLabel("Task #", 48, 64, 38, 17) GUICtrlSetState($Label2, $GUI_DISABLE) $Input1 = GUICtrlCreateInput("", 96, 64, 49, 21) GUICtrlSetState($Input1, $GUI_DISABLE) $Radio2 = GUICtrlCreateRadio("Run Sagetask:", 16, 104, 113, 17) GUICtrlSetState($Radio2, $GUI_CHECKED) $Label3 = GUICtrlCreateLabel("Task # ", 48, 128, 41, 17) $Input2 = GUICtrlCreateInput("", 96, 128, 49, 21) GUICtrlSetState($Input2, $GUI_FOCUS) $Button1 = GUICtrlCreateButton("Go!", 176, 104, 75, 49, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Radio1 GUICtrlSetState($Label2, $GUI_ENABLE) GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetState($Label3, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_DISABLE) GUICtrlSetState($Input1, $GUI_FOCUS) Case $Radio2 GUICtrlSetState($Label3, $GUI_ENABLE) GUICtrlSetState($Input2, $GUI_ENABLE) GUICtrlSetState($Label2, $GUI_DISABLE) GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_FOCUS) Case $Button1 $iRun = GUICtrlRead($Radio1) If $iRun = 4 Then ShellExecute("cleanmgr", "/SAGERUN:1") Else ShellExecute("cleanmgr", "/sageset:1") EndIf Exit EndSwitch WEnd
  6. Tonight, I wanted to be able to add a tab to my GUI like some programs allow with a plus sign on the end. I couldn't find any examples in my search (although I did see a cool UDF that was more complicated than I wanted - and still no plus sign). So, here's what I came up with (oh, right click the tab to be able to delete the current tab that you are on): #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <Array.au3> $sAddTabSymbol = " +" Global $aTabs[100] ; make whatever you want or with more code, it can be dynamic $Form1 = GUICreate("My Tabbed Form", 625, 442) $aTabs[0] = GUICtrlCreateTab(16, 24, 585, 385) $Tab1 = $aTabs[0] $aTabs[1] = _GUICtrlTab_InsertItem($Tab1, 0, "TabSheet1") $aTabs[2] = _GUICtrlTab_InsertItem($Tab1, 1, $sAddTabSymbol) $Menu1 = GUICtrlCreateContextMenu($aTabs[0]) $MenuDelTab = GUICtrlCreateMenuItem("Delete Current Tab", $Menu1) GUICtrlSetState(-1,$GUI_SHOW) GUICtrlCreateTabItem("") _GUICtrlTab_SetCurSel($Tab1, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Tab1 $iPos = GUICtrlRead($Tab1) $sTabText = _GUICtrlTab_GetItemText($Tab1, $iPos) If $sTabText = $sAddTabSymbol Then $sAns = InputBox("Create New Tab", "Enter new tab name: ", "New Tab") If $sAns <> "" Then _GUICtrlTab_InsertItem($Tab1, $iPos, $sAns) _GUICtrlTab_SetCurSel($Tab1, $iPos) EndIf EndIf Case $MenuDelTab $iPos = GUICtrlRead($Tab1) $sTabText = _GUICtrlTab_GetItemText($Tab1, $iPos) $iAns = MsgBox(4, "Delete Current Tab", "Do you really want to delete the current tab:" & @CRLF & @CRLF & $sTabText) If $iAns = 6 Then _GUICtrlTab_DeleteItem($Tab1, $iPos) _GUICtrlTab_SetCurSel($Tab1, $iPos - 1) EndIf EndSwitch WEnd
  7. I have had similar troubles with 32-bit dlls. There are two ways I use to make sure I run the AutoIt script as 32 bit to work properly with 32 bit dlls: 1. Compile the script to a 32 bit executable. 2. Right-click the script and go to the bottom option "Run Script (x86)". But yeah, since it is working now that you have your 32 bit stuff sorted out, that was your problem.
  8. I made some modifications. For one, I used GUISetAccelerators to make the Enter key activate the hashing process if you paste or type the file location into the input box. Second, I noticed that dropping a file, the combo and a new method I added all did the same things, so I combined them into one Case. Third, to save space, I converted your selector of the the algorithms into an array. Lastly, and in most importantly, I added a tooltip to show the whole output when you hover over the output. Being in a disabled state, you cannot scroll the text to see the whole string, so if it is too big for the box (and many are), then the what you see is useless. I also added an option to put the results in the clipboard. If you want to enable it, just delete the semicolon. I hope these examples give you some ideas on how you can get things done in AutoIt. #include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Array.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) GUISetState(@SW_SHOW, $hGUI) $idDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $idDummy]] GUISetAccelerators($aAccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_DROPPED, $idCombo, $idDummy $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFileName, $Progress1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else Local $dHash = 0 _Crypt_Startup() Local $aCrypt[8][2] = [["MD2 (128bit)", $CALG_MD2],["MD4 (128bit)", $CALG_MD4],["MD5 (128bit)",$CALG_MD5],["SHA1 (160bit)",$CALG_SHA1],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_384 (384bit)",$CALG_SHA_384],["SHA_512 (512bit)",$CALG_SHA_512]] $hashSelect = GUICtrlRead($idCombo) $hashLoc = _ArraySearch($aCrypt, $hashSelect) $hashAlgo = $aCrypt[$hashLoc][1] $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) GUICtrlSetTip($g_idOutputEdit, $hexHash) ;ClipPut($hexHash) ; copies hash value to clipboard _Crypt_Shutdown() EndIf EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile
  9. If you are interested in the progressbar version, I got it working. When something is changed (the combo or a new file put in), I made it clear out the old data so you won't glance at it and think it's done. #include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GuiEdit.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_PRIMARYDOWN _GUICtrlEdit_SetSel($idInput, 0, -1) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFileName, $Progress1) Case $idCombo $sFileName = GUICtrlRead($idInput) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFileName, $Progress1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile Edit: added code to prevent dragging a new file into the input box and concatenating them instead of overwriting the last file location.
  10. And out of curiosity if I can do it, I'm trying to get a progressbar working. I think I'm close, but no luck so far.
  11. I overlooked that. Simple fix. #include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) _Hash($sFile) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput) _Hash($sFileName) Case $idCombo $sFileName = GUICtrlRead($idInput) _Hash($sFileName) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc
  12. I made some modifications that eliminate the WM_Command. I tried this code with a 3.3 GB file. It took about 10 seconds to hash, but the gui did not lock up. #include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) _Hash($sFile) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput) _Hash($sFileName) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc
  13. I meant to mark argumentum's post as the solution. He's the hero today!
  14. Thanks, argumentum! AutoIt3Wrapper.au3 compiles it silently and uses the wrappers. Perfect solution. All I need is to shellexecute it and run the specify the script.
  15. Hi, everyone! I am able to compile from command line and got everything to work except specifying the language. I understand the wrapper uses a 4 digit number for the languages and tried that. However, nothing worked and I do not think there is a switch for specifying the language at all. Is this correct? I also tried writing wrappers to the header and they compile fine if I do so manually, but compiling from command line ignores the wrappers. Is there any way to compile from command line and use the wrappers? I also noticed that "compile with options" does not use Aut2exe, rather it uses AutoIt3.exe (or at least this disappears in task manager when I close the window). Could I possibly pass arguments to it compile? I tried some things, but just get errors. Any insight into this would be appreciated. Thanks!
×
×
  • Create New...