Jump to content
Sign in to follow this  
ForsakenGod

List & If clicked

Recommended Posts

ForsakenGod

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ForsakenGod

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ForsakenGod

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 ! : )

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ForsakenGod

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ForsakenGod

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

Ohh cool that does the trick ! :D

Thank you

Share this post


Link to post
Share on other sites
ForsakenGod

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ForsakenGod

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

Share this post


Link to post
Share on other sites
Fire

+ 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]

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.