Sign in to follow this  
Followers 0
xdp22

Txt lines in listbox

6 posts in this topic

Hello, how to display txt file lines, in listbox?

Example - in file1.txt we have lines :

1

2

3

4

And in listbox we have :

1

2

3

4

Thanks

Share this post


Link to post
Share on other sites



xdp22,

Use _FileReadToArray to get the file into an array. Then loop through the array and use GUICtrlSetData to add to the List control like this:

#include <GUIConstantsEx.au3>

; Simulate loading lines from the file
Global $aArray[4] = [3, "Line 1", "Line 2", "Line 3"]

$hGUI = GUICreate("Test", 500, 500)

$hList = GUICtrlCreateList("", 10, 10, 200, 200)

For $i =1 To $aArray[0]
    GUICtrlSetData($hList, $aArray[$i])
Next

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

All clear? :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks, i have one more ask, not for this topic, but i don't want create next topic, can i ask here? :x

I have big problem i try example it what i want to make, and i show you the code what don't work for me.

I created gui, with 1 input and 5 buttons, one button = create, next = delete, next = clear, next = Start, next = Stop, when i click button Create, i want to make a way, script will take text from input, and create folder with name like input, in this folder create .txt file, and this script wait to press home key, when home key pressed script make screenshoot 100x100 from mouse cursor (remember u helped me in script), this screenshot is saved in this folder what script maked, and screenshot name was added in this .txt file in this folder.

So in example, if u click home 4x, script will make 4x screenshots, with name 1.bmp, 2.bmp, 3.bmp, 4.bmp, and make 4 lines in txt file, 1.bmp, 2.bmp, etc.

This is end what script make with create button, button Start is button to start program work, program will use "waypoints", search 1.bmp and click on it, search 2.bmp and click on it, search 3.bmp and click on it, search 4.bmp and click on it, and when end it should make it back, so he will search and click on 4.bmp, 3.bmp, 2.bmp, and 1.bmp, and next 1.bmp, 2.bmp and roll, roll, roll.

In listbox, was just txt file, remove just remove screenshot what we select in listbox, and clear just clear all screenshots from listbox, so delete 1.bmp, 2.bmp etc.

But i need help only with create and with start i think, listbox, and remove is not needed so much.

It is possible to help me with that?

I don't start making start button, cuz i had problem with create button, here is my program :

Include <ScreenCapture.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <array.au3>
#Include <File.au3>
#include <string.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 325, 386, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 305, 21)
$Button1 = GUICtrlCreateButton("Button1", 8, 48, 305, 17)
$Delete = GUICtrlCreateButton("Delete", 16, 120, 145, 17)
$Clear = GUICtrlCreateButton("Clear", 16, 144, 145, 17)
$List1 = GUICtrlCreateList("", 176, 112, 129, 214)
$Start = GUICtrlCreateButton("Start", 24, 232, 137, 33)
$Stop = GUICtrlCreateButton("Stop", 24, 280, 137, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $folder = GUICtrlRead($Input1)
Global $plik = @ScriptDir & "\" & $folder


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         
     EndSwitch
    Switch $nMsg
        Case $Button1
            DirCreate($folder)
            FileWriteLine($plik & "\" & $folder & ".txt", "")
                        wpt()
    EndSwitch
WEnd




; Create exit mode
HotKeySet("{ESC}", "On_Exit")

Func wpt()
While 1
$dll = DllOpen("user32.dll")

    ; Wait for mouse click
     If _IsPressed("24", $dll) Then
        ; Get mouse position
        $aMPos = MouseGetPos()
        $iLeft   = $aMPos[0] - 50
        $iTop    = $aMPos[1] - 50
        $iRight  = $aMPos[0] + 50
        $iBottom = $aMPos[1] + 50
        ; Capture that area
        $wpt = _FileCountLines($plik & "\" & $folder & ".txt")
        _ScreenCapture_Capture($plik & "\" & $wpt & ".bmp", $iLeft, $iTop, $iRight, $iBottom, False)
        FileWriteLine($plik, $wpt)
        wpt()
        Do
            Sleep(10)
        Until Not(_IsPressed("24", $dll))

     EndIf

 WEnd

EndFunc

Func On_Exit()
    DllClose($dll)
    Exit
EndFunc

Thank you.

Edited by xdp22

Share this post


Link to post
Share on other sites

xdp22,

How to make the 4 images: :x

#Include <ScreenCapture.au3 >
#include <Misc.au3>
#include <WinAPI.au3>
#include <array.au3>
#include <File.au3>
#include <string.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

Global $dll = DllOpen("user32.dll")
Global $plik

$Form1 = GUICreate("Form1", 325, 386, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 305, 21)
$Button1 = GUICtrlCreateButton("Button1", 8, 48, 305, 17)
$Delete = GUICtrlCreateButton("Delete", 16, 120, 145, 17)
$Clear = GUICtrlCreateButton("Clear", 16, 144, 145, 17)
$List1 = GUICtrlCreateList("", 176, 112, 129, 214)
$Start = GUICtrlCreateButton("Start", 24, 232, 137, 33)
$Stop = GUICtrlCreateButton("Stop", 24, 280, 137, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Stop
            DllClose($dll)
            Exit
        Case $Button1
            $folder = GUICtrlRead($Input1)
            $plik = @ScriptDir & "\" & $folder
            DirCreate($folder)
            ; `FileWriteLine($plik & "\" & $folder & ".txt", "") ; Not sure you will need this now <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            wpt()
    EndSwitch
WEnd

Func wpt()

    ; We need 4 images
    For $i = 1 To 4

        While 1
            ; Wait for Home key
            If _IsPressed("24", $dll) Then
                ; Get mouse position
                $aMPos = MouseGetPos()
                $iLeft = $aMPos[0] - 50
                $iTop = $aMPos[1] - 50
                $iRight = $aMPos[0] + 50
                $iBottom = $aMPos[1] + 50
                ; Capture that area - image number comes from the loop index
                _ScreenCapture_Capture($plik & "\" & $i & ".bmp", $iLeft, $iTop, $iRight, $iBottom, False)
                ; FileWriteLine($plik, $i & ".bmp") ; Not sure you will need this now <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                Do
                    Sleep(10)
                Until Not (_IsPressed("24", $dll))
                ExitLoop
            EndIf

        WEnd

    Next

EndFunc   ;==>wpt

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks, you are great programmer.

Share this post


Link to post
Share on other sites

xdp22,

No - just more experienced than you. Keep learning and you will soon be teaching me new things! :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  
Followers 0