Jump to content

A way to select a list of items from an Array


Recommended Posts

Usually when I collect data from DataBase I need to give EndUser a possibility to select rows which should be taken in the processing loop.
I was searching on the forum and I'm not able to find any UDF or even example of how to select data from array.
I have my own solutions but I think they are not worth posting on the forum as it is very old code and I am looking for a better solution.

Could anybody point me to some examples/solutions ?

Thank you in advance.
@mLipok

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

Thanks. Interesting.

I would prefer something like ArrayDisplay which will give you all selected ID's


 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

Well, I forgot about this magical corner.
There are many examples of displaying data from a database. I have to prepare something ...

I think I will refactor my current function and show it here. Then the conversation will be more precise.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

As I said this is my old code.... so....
Here is my "some way refactored" code:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

_Example()
Func _Example()
    Local $a_Test[100][10]
    For $ROW = 0 To 99
        For $COL = 0 To 9
            $a_Test[$ROW][$COL] = 'Test #' & $COL
        Next
    Next

    Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False)
    _ArrayDisplay($a_Selected, '$a_Selected')
EndFunc   ;==>_Example


Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0)
    If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array")

    Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS)
    Local $i_Temp_Cols_Count
    If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0
    If $i_Source_Cols_Count = 0 Then ; If 1D Array
        $i_Temp_Cols_Count = $i_Source_Cols_Count + 1
    Else
        $i_Temp_Cols_Count = $i_Source_Cols_Count
    EndIf

    Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count]
    If $b_ArrayHasHeader Then
        For $icols = 0 To $i_Temp_Cols_Count - 1
            For $irows = 0 To $i_Source_Rows_Count - 1
                If $i_Source_Cols_Count > 0 Then
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows][$icols]
                Else
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows]
                EndIf
            Next
        Next
    EndIf

    Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent)
    GUISetFont(8.5)
    GUICtrlCreateLabel($s_Information, 8, 8, 900, 50)
    Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1)

    Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW)

    #Region - FillUp ListView
    _GUICtrlListView_BeginUpdate($h_ListView_Wybierz)
    Local $a_Processing
    If $b_ArrayHasHeader Then
        $a_Processing = $a_Temp_2
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a])
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0])
        EndIf
    Else
        $a_Processing = $a_Source
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
        EndIf
    EndIf

    For $id_X_Row = 0 To $i_Source_Rows_Count - 1
        _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0])
        For $id_X_Col = 0 To $i_Temp_Cols_Count - 1
            _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col)
        Next
    Next
    _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2)
    Send("{CTRLDOWN}{SHIFTDOWN}")
    ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}")
    Send("{SHIFTUP}{CTRLUP}")
    If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0)
    _GUICtrlListView_EndUpdate($h_ListView_Wybierz)
    #EndRegion - FillUp ListView

    Local $nMsg
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $id_Button_Select
                If _GUICtrlListView_GetSelectionMark($h_ListView_Wybierz) = -1 Then
                    GUIDelete($hGuiForm_1)
                    Return SetError(1, 0, "Nie dokonano wyboru")
                EndIf
                Local $a_Result = StringSplit(_GUICtrlListView_GetSelectedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|")
                GUIDelete($hGuiForm_1)
                If $b_ArrayHasHeader Then
                    For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej
                        $a_Result[$IDX_Choosen] += 1
                    Next
                EndIf
                Return $a_Result
            Case $id_Button_Cancel, $GUI_EVENT_CLOSE
                GUIDelete($hGuiForm_1)
                Return SetError(1, 0, "Nie dokonano wyboru")
        EndSwitch
    WEnd
EndFunc   ;==>_Array_Select

Any ideas for improvement would be appreciated.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

@mLipok I slightly improved the UI by adding check marks for selection:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

_Example()
Func _Example()
    Local $a_Test[100][10]
    For $ROW = 0 To 99
        For $COL = 0 To 9
            $a_Test[$ROW][$COL] = 'Test #' & $COL
        Next
    Next

    Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False)
    _ArrayDisplay($a_Selected, '$a_Selected')
EndFunc   ;==>_Example


Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0)
    If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array")

    Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS)
    Local $i_Temp_Cols_Count
    If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0
    If $i_Source_Cols_Count = 0 Then ; If 1D Array
        $i_Temp_Cols_Count = $i_Source_Cols_Count + 1
    Else
        $i_Temp_Cols_Count = $i_Source_Cols_Count
    EndIf

    Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count]
    If $b_ArrayHasHeader Then
        For $icols = 0 To $i_Temp_Cols_Count - 1
            For $irows = 0 To $i_Source_Rows_Count - 1
                If $i_Source_Cols_Count > 0 Then
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows][$icols]
                Else
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows]
                EndIf
            Next
        Next
    EndIf

    Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent)
    GUISetFont(8.5)
    GUICtrlCreateLabel($s_Information, 8, 8, 900, 50)
    Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1)

    Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW)

    #Region - FillUp ListView
    _GUICtrlListView_BeginUpdate($h_ListView_Wybierz)
    Local $a_Processing
    If $b_ArrayHasHeader Then
        $a_Processing = $a_Temp_2
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a])
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0])
        EndIf
    Else
        $a_Processing = $a_Source
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
        EndIf
    EndIf

    For $id_X_Row = 0 To $i_Source_Rows_Count - 1
        _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0])
        For $id_X_Col = 0 To $i_Temp_Cols_Count - 1
            _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col)
        Next
    Next
    _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2)
    Send("{CTRLDOWN}{SHIFTDOWN}")
    ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}")
    Send("{SHIFTUP}{CTRLUP}")
    If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0)
    _GUICtrlListView_EndUpdate($h_ListView_Wybierz)
    #EndRegion - FillUp ListView

    Local $nMsg
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $id_Button_Select
                Local $a_Result = StringSplit(_GUICtrlListView_GetCheckedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|")
                GUIDelete($hGuiForm_1)
                If $a_Result[0] = 0 Then Return SetError(1, 0, "Nie dokonano wyboru")
                If $b_ArrayHasHeader Then
                    For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej
                        $a_Result[$IDX_Choosen] += 1
                    Next
                EndIf
                Return $a_Result
            Case $id_Button_Cancel, $GUI_EVENT_CLOSE
                GUIDelete($hGuiForm_1)
                Return SetError(1, 0, "Nie dokonano wyboru")
        EndSwitch
    WEnd
EndFunc   ;==>_Array_Select

; #FUNCTION# ====================================================================================================================
; Author ........: Gary Frost (gafrost)
; Modified.......: Damon Harris (TheDcoder) (forked from GetSelectedIndices)
; ===============================================================================================================================
Func _GUICtrlListView_GetCheckedIndices($hWnd, $bArray = False)
    Local $tLVITEM = DllStructCreate($tagLVITEM)
    DllStructSetData($tLVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tLVITEM, "StateMask", 0xffff)

    Local $sIndices, $aIndices[1] = [0]
    Local $iRet, $iCount = _GUICtrlListView_GetItemCount($hWnd)
    For $iItem = 0 To $iCount
        DllStructSetData($tLVITEM, "Item", $iItem)
        If IsHWnd($hWnd) Then
            $iRet = _SendMessage($hWnd, $LVM_GETITEMW, 0, $tLVITEM, 0, "wparam", "struct*") <> 0
        Else
            $iRet = GUICtrlSendMsg($hWnd, $LVM_GETITEMSTATE, 0, $tLVITEM)
        EndIf
        Local $bChecked = BitAND(DllStructGetData($tLVITEM, "State"), 0x2000) <> 0
        If $bChecked Then
            If (Not $bArray) Then
                If StringLen($sIndices) Then
                    $sIndices &= "|" & $iItem
                Else
                    $sIndices = $iItem
                EndIf
            Else
                ReDim $aIndices[UBound($aIndices) + 1]
                $aIndices[0] = UBound($aIndices) - 1
                $aIndices[UBound($aIndices) - 1] = $iItem
            EndIf
        EndIf
    Next
    If (Not $bArray) Then
        Return String($sIndices)
    Else
        Return $aIndices
    EndIf
EndFunc   ;==>_GUICtrlListView_GetCheckedIndices

I added a new function called _GUICtrlListView_GetCheckedIndices which returns the indexes which are checked from a list view. Credit goes to Gary Frost as I just mashed up two of his functions (_GUICtrlListView_GetSelectedIndices and _GUICtrlListView_GetItemChecked) to create the function:thumbsup:

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Nice.
But I still prefer to selecting rows instead checking items in the listview.

Here is my improved example:
 

;~ https://www.autoitscript.com/forum/topic/207118-a-way-to-select-a-list-of-items-from-an-array/?tab=comments#comment-1493276

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

_Example(2000, 40)

Func _Example($iRows, $iCols)
    Local $a_Test[$iRows][$iCols]
    For $ROW = 0 To $iRows - 1
        For $COL = 0 To $iCols - 1
            $a_Test[$ROW][$COL] = 'Test long text here #' & $COL
        Next
    Next

    Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', True)
;~  Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False)
    _ArrayDisplay($a_Selected, '$a_Selected')
EndFunc   ;==>_Example


Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0)
    Local $hTimer = TimerInit()
    If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array")

    Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS)
    Local $i_Temp_Cols_Count
    If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0
    If $i_Source_Cols_Count = 0 Then ; If 1D Array
        $i_Temp_Cols_Count = $i_Source_Cols_Count + 1
    Else
        $i_Temp_Cols_Count = $i_Source_Cols_Count
    EndIf

    Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count]
    If $b_ArrayHasHeader Then
        For $icols = 0 To $i_Temp_Cols_Count - 1
            For $irows = 0 To $i_Source_Rows_Count - 1
                If $i_Source_Cols_Count > 0 Then
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows][$icols]
                Else
                    $a_Temp_2[$irows][$icols] = $a_Source[$irows]
                EndIf
            Next
        Next
    EndIf

    Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent)
    GUISetFont(8.5)
    GUICtrlCreateLabel($s_Information, 8, 8, 900, 50)
    Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1)

    Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW)

    #Region - FillUp ListView
    _GUICtrlListView_BeginUpdate($h_ListView_Wybierz)
    Local $a_Processing
    If $b_ArrayHasHeader Then
        $a_Processing = $a_Temp_2
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a])
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0])
        EndIf
    Else
        $a_Processing = $a_Source
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
        EndIf
    EndIf

    For $id_X_Row = 0 To $i_Source_Rows_Count - 1
        _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0])
        For $id_X_Col = 0 To $i_Temp_Cols_Count - 1
            _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col)
        Next
    Next
    _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2)
    Send("{CTRLDOWN}{SHIFTDOWN}")
    ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}")
    Send("{SHIFTUP}{CTRLUP}")
    If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0)
    _GUICtrlListView_EndUpdate($h_ListView_Wybierz)
    #EndRegion - FillUp ListView
    Local $iSeconds = TimerDiff($hTimer) / 1000
    ConsoleWrite("! $iSeconds = " & $iSeconds & @CRLF)

    Local $nMsg
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $id_Button_Select
                If _GUICtrlListView_GetSelectionMark($h_ListView_Wybierz) = -1 Then
                    GUIDelete($hGuiForm_1)
                    Return SetError(1, 0, "Nie dokonano wyboru")
                EndIf
                Local $a_Result = StringSplit(_GUICtrlListView_GetSelectedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|")
                GUIDelete($hGuiForm_1)
                If $b_ArrayHasHeader Then
                    For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej
                        $a_Result[$IDX_Choosen] += 1
                    Next
                EndIf
                Return $a_Result
            Case $id_Button_Cancel, $GUI_EVENT_CLOSE
                GUIDelete($hGuiForm_1)
                Return SetError(1, 0, "Nie dokonano wyboru")
        EndSwitch
    WEnd
EndFunc   ;==>_Array_Select

On my PC it takes about 11 second to display all the data.
My goal is to use normal ListView and not VirtualListview, but I must speed up this somehow.

I think that I must to use this following tip:

  

On 3/22/2015 at 2:17 PM, LarsJ said:

If not more than 10,000 rows have to be inserted in a listview, a standard listview is sufficiently rapid. Because of speed you should use native (built-in) functions to fill the listview and not functions in GuiListView.au3 UDF. When the listview is filled, you can use all the functions in the UDF.

 

and adopt some trick from @LarsJ LvStandard.au3

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites
  • 2 weeks later...

As for now I have this:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

_Example(2000, 40)

Func _Example($iRows, $iCols)
    Local $a_Test[$iRows][$iCols]
    For $ROW = 0 To $iRows - 1
        For $COL = 0 To $iCols - 1
            $a_Test[$ROW][$COL] = 'Test long text here #' & $ROW & "," &  $COL
        Next
    Next

;~  Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', True)
    Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False)
    _ArrayDisplay($a_Selected, '$a_Selected')
EndFunc   ;==>_Example


Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0)
    Local $hTimer = TimerInit()
    If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array")

    Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS)
    Local $i_Temp_Cols_Count
    If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0
    If $i_Source_Cols_Count = 0 Then ; If 1D Array
        $i_Temp_Cols_Count = $i_Source_Cols_Count + 1
    Else
        $i_Temp_Cols_Count = $i_Source_Cols_Count
    EndIf

    Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count]
    If $b_ArrayHasHeader Then
        For $iCols = 0 To $i_Temp_Cols_Count - 1
            For $iRows = 0 To $i_Source_Rows_Count - 1
                If $i_Source_Cols_Count > 0 Then
                    $a_Temp_2[$iRows][$iCols] = $a_Source[$iRows][$iCols]
                Else
                    $a_Temp_2[$iRows][$iCols] = $a_Source[$iRows]
                EndIf
            Next
        Next
    EndIf

    Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent)
    GUISetFont(8.5)
    GUICtrlCreateLabel($s_Information, 8, 8, 900, 50)
    Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1)

    Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0)
    GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1)
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
;~  GUISetState(@SW_SHOW)

    #Region - FillUp ListView
    _GUICtrlListView_BeginUpdate($h_ListView_Wybierz)
    Local $a_Processing
    If $b_ArrayHasHeader Then
        $a_Processing = $a_Temp_2
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a])
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0])
        EndIf
    Else
        $a_Processing = $a_Source
        If $i_Source_Cols_Count > 0 Then
            For $a = 0 To $i_Temp_Cols_Count - 1
                _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
            Next
        Else
            _GUICtrlListView_AddColumn($h_ListView_Wybierz, '')
        EndIf
    EndIf

;~  For $id_X_Row = 0 To $i_Source_Rows_Count - 1
;~      _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0])
;~      For $id_X_Col = 0 To $i_Temp_Cols_Count - 1
;~          _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col)
;~      Next
;~  Next
    FillListView($id_ListView_1, $a_Source, UBound($a_Source, 1))

    _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2)
    Send("{CTRLDOWN}{SHIFTDOWN}")
    ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}")
    Send("{SHIFTUP}{CTRLUP}")
    If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0)
    _GUICtrlListView_EndUpdate($h_ListView_Wybierz)
    #EndRegion - FillUp ListView
    GUISetState(@SW_SHOW)
    Local $iSeconds = TimerDiff($hTimer) / 1000
    ConsoleWrite("! $iSeconds = " & $iSeconds & @CRLF)

    Local $nMsg
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $id_Button_Select
                If _GUICtrlListView_GetSelectionMark($h_ListView_Wybierz) = -1 Then
                    GUIDelete($hGuiForm_1)
                    Return SetError(1, 0, "Nie dokonano wyboru")
                EndIf
                Local $a_Result = StringSplit(_GUICtrlListView_GetSelectedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|")
                GUIDelete($hGuiForm_1)
                If $b_ArrayHasHeader Then
                    For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej
                        $a_Result[$IDX_Choosen] += 1
                    Next
                EndIf
                Return $a_Result
            Case $id_Button_Cancel, $GUI_EVENT_CLOSE
                GUIDelete($hGuiForm_1)
                Return SetError(1, 0, "Nie dokonano wyboru")
        EndSwitch
    WEnd
EndFunc   ;==>_Array_Select

Func FillListView($idLV, ByRef $aItems, $iRows)
    Local $tLVITEM = DllStructCreate($tagLVITEM)
    Local $pLVITEM = DllStructGetPtr($tLVITEM), $k, $s
    DllStructSetData($tLVITEM, "Mask", $LVIF_IMAGE)   ; Icon (or image)
    DllStructSetData($tLVITEM, "SubItem", 0)          ; First column
    For $j = 0 To $iRows - 1
        ; Text
        $s = $aItems[$k + $j][0]
        For $l = 1 To UBound($aItems, 2) - 1
            $s &= "|" & $aItems[$k + $j][$l]
        Next
        GUICtrlCreateListViewItem($s, $idLV)              ; Add item and all texts
    Next
EndFunc   ;==>FillListView

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TheAlienDoctor
      Hi, I was looking into creating a script that would detect if a file exists, then move it (and in some cases rename it, depending on the file) as well as write to a log file.
      The issue is, there is a lot of files that need to be moved, sometimes some files will exist and others won't depending on the use-case. However if a file does exist, it will always be going into the same directory with the same name.
      Currently I have an array nested inside of the array, with each array inside that array having both the old and new directory, and then a For loop to actually run through and do the file transferring. The issue I am having is how to call the Array inside of the array, because how do I specify  which the old directory is and which the new is?
      Global $FileTransfer[2000] = [Global $Dir1[2] = ["original dir 1", "new dir 1"], Global $Dir2[2] = ["original dir 2", "new dir 2"]] For $FileTransfer = [0] To [1] Step +1 If FileExists({original dir}) Then FileMove({original dir}, new dir, 1) FileOpen("log.latest.txt", 1) FileWrite("log.latest.txt", "{original dir} found, moved it to new dir." & @CRLF) FileClose("log.latest.txt") Else FileOpen("log_latest.txt", 1) FileWrite("log_latest.txt", "{original dir} not found, ignoreing it." & @CRLF) FileClose("log_latest.txt") EndIf Next I have put what I want the old and new directory to be for each array in {}, so hopefully its easier to tell which part is working and whats not.

      I am still reasonably new to AutoIT, any help is appreciated. Thankyou
    • By arunkw
      I have a spreadsheet - daily routine which has two columns: activity and time as shown here
      | Activity             | Time     | |----------------------|----------| | Sleep               |  6:00 am | | Toilet              |  6:15 am | | Get ready for gym  |  6:30 am | | Exercise            |  7:50 am | | ... more things      |  9:00 pm | | ... still more       | 10:45 pm | | Sleep               |  6:00 am |   I wanted to find out, say in C1 which activity is current for me using now() I.e., if it’s 6:45am on my watch, it should show me Exercise  in C1 Thanks to Adam D. PE, this formula works like magic to get the result =VLOOKUP(MOD(NOW(),1),{B2:B,A2:A},2,1)   Now, I want to reproduce same result in autoit, how to do that? To have easy solution say, I copy-paste spreadsheet data in array directly in code, right? Use for loop and run the above vlookup function and show the answer using tooltip. How to achieve this? please help.  
    • By goku200
      I have an Autoit script that lists files from a folder into an array list. Is there a way to separate the filenames by an underscore and include the id, version, name and date into separate columns in Excel.
      Example of filename:
      12345_v1.0_TEST Name [12345]_01.01.2022.html
      12345 would be in one column
      v1.0 would be in another column
      TEST Name [12345] would be in another column
      01.01.2022 would be in another column
      .html would be in another column
      Note: filenames always change each day.
      Here is my code that lists the files into column C and then writes the column Headers into Column D, E, F, G. Just need some help with separating them into columns by the _ delimiter
       
    • By EmilyLove
      I have a string containing the full path of an executable and an array of executables without their paths. I am trying to compare the string to the list in the array and if a match is found, remove it from the array. The entry get removed from the array successfully, and after checking its return result, uses it to update the ubound if it succeeded, but it doesn't want to update to the new value. Any ideas what I am doing wrong? It acts like it is read-only.
      #include <Array.au3> #include <File.au3> Local $sApp_Exe = "F:\App\Nextcloud\nextcloud.exe" Local $aWaitForEXEX = [3, "Nextcloud.exe", "nextcloudcmd.exe", "QtWebEngineProcess.exe"] For $h = 1 To $aWaitForEXEX[0] If StringInStr($sApp_Exe, $aWaitForEXEX[$h]) <> 0 Then $iRet = _ArrayDelete($aWaitForEXEX, $h) If $iRet <> -1 Then $aWaitForEXEX[0] = $iRet ;this line doesn't work. $aWaitForEXEX[0] doesn't update and shortly gives Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _ArrayDisplay($aWaitForEXEX) EndIf Next  
    • By vinnyMS
      #Include <Array.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _ArrayDisplay($w) i have this script that returns 3 columns  
       
      i need to copy the  Col 0 and Col 1 as text to paste on notepad or excel
      you will have to create a "copy" button if possible
      array.au3 2.txt
×
×
  • Create New...