Jump to content

List & If clicked


Recommended Posts

Hello ,

I have a question i think it may be easy to solve but i cant figure it out :D 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 :huggles:

Thanks in advance ,

Unreal

Edited by ForsakenGod
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

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 by ForsakenGod
Link to comment
Share on other sites

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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 ! : )
Link to comment
Share on other sites

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

You can drop the code with FileFindFirstFile etc. See posting 4 for the shortened code.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

#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 :D 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 ? :huggles:

Link to comment
Share on other sites

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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 :D

Link to comment
Share on other sites

+ you can try this too:(sorry for unclear i wrote it at midnight)

#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 by Sh3llC043r
[size="5"] [/size]
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...