Clanity184 Posted November 25, 2016 Share Posted November 25, 2016 (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 November 25, 2016 by Clanity184 Link to comment Share on other sites More sharing options...
water Posted November 25, 2016 Share Posted November 25, 2016 What have you tried so far? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Clanity184 Posted November 25, 2016 Author Share Posted November 25, 2016 (edited) Hello water, i did some tests, but without getting anything.. Here the skeleton code: expandcollapse popup#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 November 25, 2016 by Clanity184 Link to comment Share on other sites More sharing options...
water Posted November 25, 2016 Share Posted November 25, 2016 Something like this? expandcollapse popup#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 (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Clanity184 Posted November 25, 2016 Author Share Posted November 25, 2016 Something wrong.. Link to comment Share on other sites More sharing options...
water Posted November 25, 2016 Share Posted November 25, 2016 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 (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Clanity184 Posted November 25, 2016 Author Share Posted November 25, 2016 You're right, thanks!! Link to comment Share on other sites More sharing options...
water Posted November 25, 2016 Share Posted November 25, 2016 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Clanity184 Posted November 26, 2016 Author Share Posted November 26, 2016 (edited) Sorry water, i'm a beginner. Something don't turn the right way.. expandcollapse popup#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. Edited November 26, 2016 by Clanity184 Link to comment Share on other sites More sharing options...
water Posted November 26, 2016 Share Posted November 26, 2016 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: expandcollapse popup#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 (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Clanity184 Posted November 26, 2016 Author Share Posted November 26, 2016 Now is working.. you're big.. Link to comment Share on other sites More sharing options...
water Posted November 26, 2016 Share Posted November 26, 2016 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now