Clanity184

Form with combobox and 3 buttons

12 posts in this topic

#1 ·  Posted (edited)

Hi everyone, I need some help. Is there an example to work on a form with a combo box that lets you select from a specific folder a .txt file for which then has to be manipulated by copying and renaming it? Sorry for my bad English.

Thanks for reading.

Edited by Clanity184

Share this post


Link to post
Share on other sites



What have you tried so far?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello water,

i did some tests, but without getting anything..

Here the skeleton code:

 

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Importa_Preventivo()

Func Importa_Preventivo()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Importa Preventivi", 440, 540)

    ; Create a button control.
    Local $DaNuovo = GUICtrlCreateButton("Importa preventivo da [Nuovo scontrino]", 20, 330, 395, 35)
    Local $DaTipRig = GUICtrlCreateButton("Importa preventivo da campo [Tipo rigo]", 20, 380, 395, 35)
    Local $Close = GUICtrlCreateButton("Esci", 20, 430, 395, 35)


    Local $idCombo

    ; Create GUI
    $idCombo = GUICtrlCreateCombo("", 20, 20, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))

    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, "C:\Users\Pc\Desktop\orig\" & "\*.txt")
    _GUICtrlComboBox_EndUpdate($idCombo)





    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ;Local $iPID = 0

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Close
                ExitLoop

            Case $DaNuovo

            Case $DaTipRig

            Case $Close



        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

EndFunc   ;==>Importa_Preventivo

 

Edited by Clanity184

Share this post


Link to post
Share on other sites

Something like this?

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Importa_Preventivo()

Func Importa_Preventivo()

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Importa Preventivi", 440, 540)
    ; Create a button control.
    Local $DaNuovo = GUICtrlCreateButton("Importa preventivo da [Nuovo scontrino]", 20, 330, 395, 35)
    Local $DaTipRig = GUICtrlCreateButton("Importa preventivo da campo [Tipo rigo]", 20, 380, 395, 35)
    Local $Close = GUICtrlCreateButton("Esci", 20, 430, 395, 35)
    Local $idCombo = GUICtrlCreateCombo("", 20, 20, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)
    ; Add files
    Local $aFiles = _FileListToArray("C:\temp\", "*.txt") ; <== Modify
    Local $sFiles = _ArrayToString($aFiles, Default, 1)
    GUICtrlSetData($idCombo, $sfiles)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)
    ;Local $iPID = 0
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Close
                ExitLoop
            Case $DaNuovo
            Case $DaTipRig
            Case $Close
        EndSwitch
    WEnd
    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

EndFunc   ;==>Importa_Preventivo

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Something wrong..

 

Cattura.PNG

Cattura.PNG

Share this post


Link to post
Share on other sites

In my example the line I marked as "; <== Modify" should read:

Local $aFiles = _FileListToArray("C:\users\PC\desktop\orig\", "*.txt") ; <== Modify

Note: You had a "&" where there should be a ",".


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You're right, thanks!!

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Sorry water, i'm a beginner. Something don't turn the right way..

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Importa_Preventivo()

Func Importa_Preventivo()

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Importa Preventivi", 440, 540)
    ; Create a button control.
    Local $DaNuovo = GUICtrlCreateButton("Importa preventivo da [Nuovo scontrino]", 20, 330, 395, 35)
    Local $DaTipRig = GUICtrlCreateButton("Importa preventivo da campo [Tipo rigo]", 20, 380, 395, 35)
    Local $Close = GUICtrlCreateButton("Esci", 20, 430, 395, 35)
    Local $idCombo = GUICtrlCreateCombo("", 20, 20, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)
    ; Add files
    Local $aFiles = _FileListToArray("C:\Users\Pc\Desktop\orig\", "*.txt") ; <== Modify
    Local $sFiles = _ArrayToString($aFiles, Default, 1)
    GUICtrlSetData($idCombo, $sfiles)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    MsgBox($MB_SYSTEMMODAL, "", $idCombo & "  */|\*  " & $sfiles)

    ;Local $iPID = 0
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Close
                ExitLoop
            Case $DaNuovo

                Local $aFiles = _FileListToArray("C:\Users\Pc\Desktop\orig\", "*.txt") ; <== Modify
                Local $sFiles = _ArrayToString($aFiles, Default, 1)
                MsgBox($MB_SYSTEMMODAL, "", $idCombo & "/|\" & $sfiles)


            Case $DaTipRig
            Case $Close
        EndSwitch
    WEnd
    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

EndFunc   ;==>Importa_Preventivo

What i need is a variable that contains the full path of the file (only one at a time)  that I chose from the combobox.

 

Cattura.PNG

Edited by Clanity184

Share this post


Link to post
Share on other sites

#10 ·  Posted

As the path is fixed it is easy to display the full path. I added the marked block of code to display the full path for the selected file:

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Importa_Preventivo()

Func Importa_Preventivo()

    Local $sPath = "C:\temp\", $sFilter = "*.txt" ; <== Modify
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Importa Preventivi", 440, 540)
    ; Create a button control.
    Local $DaNuovo = GUICtrlCreateButton("Importa preventivo da [Nuovo scontrino]", 20, 330, 395, 35)
    Local $DaTipRig = GUICtrlCreateButton("Importa preventivo da campo [Tipo rigo]", 20, 380, 395, 35)
    Local $Close = GUICtrlCreateButton("Esci", 20, 430, 395, 35)
    Local $idCombo = GUICtrlCreateCombo("", 20, 20, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)
    ; Add files
    Local $aFiles = _FileListToArray($sPath, $sFilter)
    Local $sFiles = _ArrayToString($aFiles, Default, 1)
    GUICtrlSetData($idCombo, $sFiles)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)
    ;Local $iPID = 0
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Close
                ExitLoop
            Case $DaNuovo
                $aFiles = _FileListToArray($sPath, $sFilter)
                $sFiles = _ArrayToString($aFiles, Default, 1)
            Case $DaTipRig
            Case $Close
                ; Following selection has been added
            Case $idCombo
                $sComboRead = GUICtrlRead($idCombo)
                MsgBox($MB_ICONINFORMATION, "Selection", "Selected file: " & $sPath & $sComboRead)
        EndSwitch
    WEnd
    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

EndFunc   ;==>Importa_Preventivo

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

Now is working.. you're big.. :)

Share this post


Link to post
Share on other sites

#12 ·  Posted

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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