ForsakenGod Posted January 26, 2010 Posted January 26, 2010 (edited) Hello , I have a question i think it may be easy to solve but i cant figure it out lets say i have gui like this #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input1", 24, 48, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I would like to ask if in list would be possible to list files of certain format (like .ini,.txt or so ) in a specific folder and after they are clicked (selected) in the list they should be readet and put some variables into those 2 input boxes (the reading function is easy i am only not sure how to make it IF selected ) i know it maz look like an gui problem but its mostlz coding Thanks in advance , Unreal Edited January 26, 2010 by ForsakenGod
water Posted January 26, 2010 Posted January 26, 2010 Hi, something like this. It allows to select multiple files (*.txt). $Path = FileOpenDialog("Please select a file","C:\temp","Text files (*.txt)", 4) 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
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 (edited) Hi, something like this. It allows to select multiple files (*.txt). $Path = FileOpenDialog("Please select a file","C:\temp","Text files (*.txt)", 4) Well thats another possibility but i would like to list them into the List entity of my gui after programm start You know like when it starts up it should look in certain directory for lets say all .txt files and list them into the $List1 Edited January 26, 2010 by ForsakenGod
water Posted January 26, 2010 Posted January 26, 2010 (edited) Or something like that: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) #EndRegion ### END Koda GUI section ### _GUICtrlListBox_Dir($List1, "C:\temp\*.txt") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 GUICtrlSetData($Input1, _GUICtrlListBox_GetText ($List1,_GUICtrlListBox_GetCurSel($List1))) EndSwitch WEnd Edited January 26, 2010 by water 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
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 Or something like that: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) #EndRegion ### END Koda GUI section ### _GUICtrlListBox_Dir($List1, "C:\temp\*.txt") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 GUICtrlSetData($Input1, _GUICtrlListBox_GetText ($List1,_GUICtrlListBox_GetCurSel($List1))) EndSwitch WEnd Eeeh well thanks for me its not working atm but ill try to get on it ty for advisE ! : )
water Posted January 26, 2010 Posted January 26, 2010 (edited) Not working means the ListBox is empty? In this case change the _GUICtrlListBox_Dir($List1, "C:\temp\*.txt")line to the directory and file of your liking. Edited January 26, 2010 by water 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
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 Not working means the ListBox is empty? In this case change the _GUICtrlListBox_Dir($List1, "C:\temp\*.txt")line to the directory and file of your liking. $cesta = @ScriptDir & "\test\" $search = FileFindFirstFile($cesta & "*.txt") Yes its empty but idk why my test dir has 3 txt s in it and it does not show even 1 of them
water Posted January 26, 2010 Posted January 26, 2010 (edited) You can drop the code with FileFindFirstFile etc. See posting 4 for the shortened code. Edited January 26, 2010 by water 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
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 You can drop the code with FileFindFirstFile etc. See posting 4 for the shortened code.Ohh cool that does the trick ! Thank you
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) #EndRegion ### END Koda GUI section ### Global $cesta = @ScriptDir & "\test\" _GUICtrlListBox_Dir($List1, $cesta & "*.txt") GUISetState(@SW_SHOW) While 1 $currentfile = _GUICtrlListBox_GetCurSel($List1) $subor = FileOpen($cesta & $currentfile , 1) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 GUICtrlSetData($Input1, FileReadLine($subor , 1)) EndSwitch WEnd One more little question Here is the code i now have it now lists all the files but after clicking on them i would like to read the 1 st line of them an input it into the $Input1 but mine stays empty any idea where is my mistake ?
water Posted January 26, 2010 Posted January 26, 2010 (edited) This should work: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) #EndRegion ### END Koda GUI section ### Global $cesta = @ScriptDir & "\test\" _GUICtrlListBox_Dir($List1, $cesta & "*.txt") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 $currentfile = GuiCtrlRead($List1) $subor = $cesta & $currentfile GUICtrlSetData($Input1, FileReadLine($subor , 1)) EndSwitch WEnd Now I'm off for today - see you tomorrow. Edited January 26, 2010 by water 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
ForsakenGod Posted January 26, 2010 Author Posted January 26, 2010 This should work: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Global $Form1 = GUICreate("Form1", 277, 411, 192, 124) Global $List1 = GUICtrlCreateList("", 24, 88, 193, 240) Global $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) Global $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) #EndRegion ### END Koda GUI section ### Global $cesta = @ScriptDir & "\test\" _GUICtrlListBox_Dir($List1, $cesta & "*.txt") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 $currentfile = GuiCtrlRead($List1) $subor = $cesta & $currentfile GUICtrlSetData($Input1, FileReadLine($subor , 1)) EndSwitch WEnd Now I'm off for today - see you tomorrow. Thanks ill try it out
Fire Posted January 26, 2010 Posted January 26, 2010 (edited) + you can try this too:(sorry for unclear i wrote it at midnight) expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #Include <GuiListView.au3> Global $avarray,$i DirCreate("test") ;create test dir For $i=0 to 20 FileWrite(@ScriptDir & "\test\" & "TESTFILE1" & $i & ".txt","THIS IS A TEST FILE" & @CRLF) Next If FileExists(@ScriptDir & "\log.dat") Then FileDelete(@ScriptDir & "\log.dat") EndIf $run=RunWait("cmd.exe /c " & "DIR /B test\*.txt >>log.dat",@ScriptDir,@SW_HIDE) _FileReadToArray(@ScriptDir & "\log.dat",$avarray) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 277, 411, 192, 124) $List1 = GUICtrlCreateListView(" |", 24, 88, 193, 240) $Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 24, 48, 121, 21) $Button1 = GUICtrlCreateButton("Name", 24, 352, 73, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("DELETE FILE", 176, 352, 73, 25, $WS_GROUP) For $i=1 to $avarray[0] $item=GUICtrlCreateListViewItem($avarray[$i],$List1) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE FileDelete(@ScriptDir & "\log.dat") Exit Case $Button1 $this=_GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($List1)) $sa=_GUICtrlListView_GetItemText(GUICtrlGetHandle($List1),$this) GUICtrlSetData($Input1,$sa) Case $Button2 FileDelete(@ScriptDir & "\test\" & _GUICtrlListView_GetItemText(GUICtrlGetHandle($List1),_GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($List1)))) GUICtrlSetData($Input2,_GUICtrlListView_GetItemText(GUICtrlGetHandle($List1),_GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($List1))) & " <=deleted") EndSwitch WEnd Edited January 26, 2010 by Sh3llC043r [size="5"] [/size]
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