Jump to content

Trying to get listbox selection into a command line executable


Recommended Posts

I think I have done pretty well so far ;) (well its just a lot of stolen code from here and there really). My goal it to select files from a folder and batch process the selected ones.

I have a gui that loads a list of files from a folder which can be chosen. The last folder used is automatically selected. The files are listed in a listbox of which I can then choose which I want to process. .... Now I want to hit the "process" button and pass just the selected files through to a function that will process them one at a time. (batchProcess at the bottom of the script)

Is the selection already stored? or do I have to make a new array to store them, in which case where would I put that and how would I pass the selection into it? My guess would be that it needs to be the first thing in the process function?

Any help would be appreciated :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
#include <Array.au3>

$Form1 = GUICreate("ToonBoom Batcher", 176, 265, 192, 124)
$Label1 = GUICtrlCreateLabel("Animate Pro Batch", 0, 5, 175, 17, $SS_CENTER)
$hListBox = GUICtrlCreateList("", 9, 56, 159, 169, BitOr($GUI_SS_DEFAULT_LIST, $LBS_EXTENDEDSEL))
$btn_fol = GUICtrlCreateButton("Select folder to render...", 8, 24, 163, 25)
$btn_sel_all = GUICtrlCreateButton("All", 9, 232, 40, 25)
$btn_sel_none = GUICtrlCreateButton("None", 50, 232, 40, 25)
$btn_ren = GUICtrlCreateButton("batch process", 96, 232, 73, 25)
GUISetState(@SW_SHOW)

$lastDir = (FileReadLine(@ScriptDir & "\lastFolder.txt", -1))
$ordner = $lastDir
$dateien = _FileListToArray($ordner, "*", 1)
;_GUICtrlListBox_BeginUpdate($hListBox)
For $i = 1 To UBound($dateien) - 1
   _GUICtrlListBox_AddString($hListBox, $dateien[$i])
Next
;_GUICtrlListBox_EndUpdate($hListBox)
;Sleep(5000);5 seconds

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $btn_fol
  ScanFolder("")
Case $msg = $btn_sel_all
  SelectAll()
Case $msg = $btn_sel_none
  SelectNone()
    Case $msg = $btn_ren
  batchProcess($dateien)
  Case Else  
  ;;;;;;;
    EndSelect
WEnd

Func ScanFolder($SourceFolder)

$ordner = FileSelectFolder("Choose folder", "" ,"$lastDir")
FileWriteLine(@ScriptDir & "\lastFolder.txt", $ordner)
$dateien = _FileListToArray($ordner, "*", 1)
;_GUICtrlListBox_BeginUpdate($hListBox)
For $i = 1 To UBound($dateien) - 1
   _GUICtrlListBox_AddString($hListBox, $dateien[$i])
Next
;_GUICtrlListBox_EndUpdate($hListBox)
   EndFunc

Func SelectAll()
            ;_GUICtrlListBox_BeginUpdate($hListBox)
            GUICtrlSendMsg($hListBox, $LB_SETSEL, True, -1)
           ;_GUICtrlListBox_EndUpdate($hListBox)
EndFunc
  
Func SelectNone()
            ;_GUICtrlListBox_BeginUpdate($hListBox)
            GUICtrlSendMsg($hListBox, $LB_SETSEL, False, -1)
            ;_GUICtrlListBox_EndUpdate($hListBox)
EndFunc


Func batchProcess($contents)
   Run(@ComSpec & ' /k ""C:\Program Files (x86)\IrfanView\i_view32.exe" "$contents" /print"')
EndFunc
Link to comment
Share on other sites

You know it might be easier if I could just select files instead of a folder, then as I add them from different folders they can be added to the listbox and also an array which can then be passed to the process function?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...