Jump to content

GUI array file open - exists?


The-dude
 Share

Recommended Posts

Hello,

I've been scouring the forums for an array function that I don't think even exists or is capable of being created. I'm trying to create a 2 part gui. The 1st gui consists of an input and search button - piece of cake. The 2nd gui is where I'm having trouble. The search button press will look in a fixed folder (C:\PDFS\), scan for a folder that matches the search criteria, then takes the folder contents and transposes the file names into an array while using the "-" in the file name as a delimiter to split the filename into columns - there could be 50 files too so the array would need a scroll bar. After that, I would like the user to be able to use the up and down arrows to choose a line and when the enter key is pressed it actually opens the file associated with the line, which would be a PDF. I can't find any array that has that functionality.  

Anyone's help would be greatly appreciated! I'm open to post forwards that have a similar functionality. 

 

image.thumb.png.909abc8076e5e86265ebed626064d6e2.png

 

@Subz @Melba23 @BrewManNH @Morthawt sorry for the direct call out but you've been a tremendous help on other useful scripts that I've adopted. I would say your the best of the best but I don't want to hurt anyone else's feelings lol. 

Link to comment
Share on other sites

Was bored, here is a basic example of what Zedna posted:

#include <Array.au3>
#include <ComboConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $g_sSaleOrders = @ScriptDir & "\PDS"
Global $g_aSaleOrders = _FileListToArray($g_sSaleOrders, "*", 2)
    If @error Then Exit

_GuiWindow1()

Func _GuiWindow1()
    Local $sSaleOrder
    Local $hWindow1 = GUICreate("Sales Orders", 450, 320, -1, -1, -1, $WS_EX_TOOLWINDOW)
        GUISetBkColor(0x999999)
    GUICtrlCreateLabel("SALE ORDERS#", 10, 125, 150, 30, $SS_CENTERIMAGE)
        GUICtrlSetFont(-1, 13, 800)
    Local $idSaleOrders = GUICtrlCreateCombo("Select", 150, 125, 150, 30, $CBS_DROPDOWNLIST)
        GUICtrlSetData($idSaleOrders, _ArrayToString($g_aSaleOrders, "|", 1))
        GUICtrlSetFont(-1, 13, 400)
    Local $idSearch = GUICtrlCreateButton("SEARCH", 150, 165, 150, 30)
        GUICtrlSetFont(-1, 13, 800)
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idSearch
                $sSaleOrder = GUICtrlRead($idSaleOrders)
                If $sSaleOrder = "Select" Then ContinueLoop
                GUIDelete($hWindow1)
                ExitLoop _GuiWindow2($sSaleOrder)
        EndSwitch
    WEnd
EndFunc

Func _GuiWindow2($_sSaleOrder)
    Local $sSaleOrderItem
    Local $aSaleOrder = _FileListToArray($g_sSaleOrders & "\" & $_sSaleOrder, "*.pdf", 1)
        If @error Then Return _GuiWindow1()
    Local $hWindow2 = GUICreate("Search Order", 450, 320, -1, -1, -1, $WS_EX_TOOLWINDOW)
        GUISetBkColor(0x999999)
    Local $idListView = GUICtrlCreateListView("NAME|NUMBER|SIZE|COLOR", 30, 35, 390, 250, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES))
    For $i = 1 To $aSaleOrder[0]
        GUICtrlCreateListViewItem(_ArrayToString(StringSplit(StringReplace($aSaleOrder[$i], ".pdf", ""), "-", 2), "|", 1), $idListView)
    Next
    _GUICtrlListView_SetColumnWidth($idListView, 0, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListView_SetColumnWidth($idListView, 3, $LVSCW_AUTOSIZE_USEHEADER)
    Local $idEnter = GUICtrlCreateDummy()
    GUISetState(@SW_SHOW)
    Local $aAccelKeys[1][2] = [["{ENTER}", $idEnter]]
        GUISetAccelerators($aAccelKeys)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idEnter
                $sSaleOrderItem = StringReplace(_GUICtrlListView_GetItemTextString($idListView, _GUICtrlListView_GetSelectionMark($idListView)), "|", "-") & ".pdf"
                _GUICtrlListView_SetItemChecked($idListView, _GUICtrlListView_GetSelectionMark($idListView))
                ShellExecute($g_sSaleOrders & "\" & $_sSaleOrder & "\" & $_sSaleOrder & "-" & $sSaleOrderItem)
        EndSwitch
    WEnd
    GUIDelete($hWindow2)
    _GuiWindow1()
EndFunc

 

Link to comment
Share on other sites

Hi @Subz, I appreciate the quick response and the amazing script - total time saver. I can't pinpoint exactly where it's happening but when I press enter to open the file from the array list it's adding "--" between the file extension "pdf" and the true file name. Any thoughts on that?

Link to comment
Share on other sites

17 minutes ago, The-dude said:

Hi @Subz, I appreciate the quick response and the amazing script - total time saver. I can't pinpoint exactly where it's happening but when I press enter to open the file from the array list it's adding "--" between the file extension "pdf" and the true file name. Any thoughts on that?

@Subz Never mind, it looks like the "--" is because my file names are currently in a different format than the example I was giving. It's currently "Salesorder-Team-PlayernamePlayernumber". I went ahead and added a couple extra "-" and placeholders to mimic my example provided in this post and it worked like a charm - THANK YOU!

On another note, I tried switching the drop down list out for an inputbox so the user can type the sales order number freely but it kept putting the array values in the input box. Do you have a quick remedy for that switcharoo?

Edited by The-dude
Link to comment
Share on other sites

14 minutes ago, The-dude said:

@Subz

On another note, I tried switching the drop down list out for an inputbox so the user can type the sales order number freely but it kept putting the array values in the input box. Do you have a quick remedy for that switcharoo?

Try to change $CBS_DROPDOWNLIST to $CBS_DROPDOWN in GUICtrlCreateCombo()

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...