Jump to content
AlMax3000

Compressor 7-Zip not working

Recommended Posts

Hi! editing a small compressor for the school I can't understand where I'm wrong 😟

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 565, 160, -1, -1)
$Inp = GUICtrlCreateInput("", 8, 32, 465, 21)
$Out = GUICtrlCreateInput("", 8, 64, 465, 21)
$Button1 = GUICtrlCreateButton("Browse", 480, 32, 75, 25)
$Button2 = GUICtrlCreateButton("Save", 480, 64, 75, 25)
$Button3 = GUICtrlCreateButton("Compress", 480, 128, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$7zDir = '"' & @ScriptDir & '\Bin\7z.exe"'

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
        $sFileSelectFolder =  FileSelectFolder("", "")
        GUICtrlSetData($Inp, $sFileSelectFolder)
        Case $Button2
        $sFileSaveDialog = FileSaveDialog("Save file", @WorkingDir, "(*.7z)")
        GUICtrlSetData($Out, $sFileSaveDialog)
        Case $Button3
        _Seven_Zip()
    EndSwitch
WEnd

Func _Seven_Zip()            
$cmd = Run($7zDir & " a -mx " & GUICtrlRead($Out) & " " & GUICtrlRead($Inp) & "\*")
EndFunc

 

Share this post


Link to post
Share on other sites
32 minutes ago, Nine said:

Add quotes around out and inp like you did for the exe.

not work with large files

 

$cmd = Run($7zDir & " a -mx " & "" & GUICtrlRead($Out) & " " & GUICtrlRead($Inp) & "\*")
Edited by AlMax3000

Share this post


Link to post
Share on other sites

you didn't add a double quote around the filenames!
Try:

$cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '\*"')

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Just a hint :

If you would like to have a progress bar while zipping, you can use the command line variant 7zG.exe. This might look better than the CMD console output ;). You will find 7zG.exe (also needs the 7z.dll) in the full installation of 7-Zip.

Replace :

5 hours ago, AlMax3000 said:

$7zDir = '"' & @ScriptDir & '\Bin\7z.exe"'

with :

Global $7zDir = '"' & @ScriptDir & '\Bin\7zG.exe"'

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Share this post


Link to post
Share on other sites
1 hour ago, Musashi said:

Solo un suggerimento:

Se si desidera avere una barra di avanzamento durante la compressione, è possibile utilizzare la variante da riga di comando 7zG.exe . Questo potrebbe apparire migliore dell'output della console CMD ;). Troverai 7zG.exe (necessita anche di 7z.dll ) nell'installazione completa di 7-Zip .

Sostituisci :

con :

Global  $ 7zDir  =  '"'  &  @ScriptDir  &  '\ Bin \ 7zG.exe"'

I would like to redirect the cmd to the inputbox or listbox to delete the 7z.exe window... is it possible?

Screenshot_1.thumb.jpg.48645a786ff1de053ad1e70fc549310e.jpg

Share this post


Link to post
Share on other sites
12 minutes ago, AlMax3000 said:

I would like to redirect the cmd to the inputbox or listbox to delete the 7z.exe window... is it possible?

Everything is possible.  But it is not clear (to me at least) what that means. Write some code, so we can figure what you are after.

Share this post


Link to post
Share on other sites
1 hour ago, Nine said:

Everything is possible.  But it is not clear (to me at least) what that means. Write some code, so we can figure what you are after.

$InpConsole = GUICtrlCreateInput("", 8, 176, 545, 200)
Func _Seven_Zip()   
If GuiCtrlRead($Inp) = "" or GuiCtrlRead($Out) = "" then MsgBox (64,"Controlla le caselle", "una o più caselle sono vuote")
$cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '\*"')
$InpConsole &= StdoutRead($cmd)
EndFunc

 

Share this post


Link to post
Share on other sites

ahh, I see.  Try this (untested) :

$InpConsole = GUICtrlCreateInput("", 8, 176, 545, 200)
; ....
GUICtrlSetData ($InpConsole, _Seven_Zip ())

Func _Seven_Zip()   
  If GuiCtrlRead($Inp) = "" or GuiCtrlRead($Out) = "" then Return MsgBox (64,"Controlla le caselle", "una o più caselle sono vuote")
  $cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '\*"',"",@SW_HIDE,$STDERR_MERGED)
  ProcessWaitClose ($cmd)
  Return StdoutRead($cmd)
EndFunc

 

Share this post


Link to post
Share on other sites
14 hours ago, AlMax3000 said:

I would like to redirect the cmd to the inputbox or listbox to delete the 7z.exe window... is it possible? 

Screenshot_1.thumb.jpg.48645a786ff1de053ad1e70fc549310e.jpg

You should check out my Process UDF which is exactly what it is supposed to do that and it even has an example of a GUI which shows you the output of a command:

 


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...