Jump to content

Recommended Posts

Posted (edited)

Hello everybody,

Sorry for my bad english.

 

I try to figure out if I have a dynamic listview with as many items as I want, how to save to a text file all the data listview contains in the same form that you put when you create a listviewitem. I will give you an example.

When the script is running it will show you the listview and some items. How to take the items data "Data1|Data1_Sub1|Data1_Sub2" in this format and paste into a text file? All of them.

I tried to explain as good as I can.

Thank you for your attention!

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

$Form_Menu = GUICreate("Form Example", 351, 234, -1, -1)

$Form_Menu_ListView1 = GUICtrlCreateListView("Column #1|Column #2|Column #3", 0, 0, 346, 230)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)

GUICtrlCreateListViewItem("Data1|Data1_Sub1|Data1_Sub2", $Form_Menu_ListView1)
GUICtrlCreateListViewItem("Data2|Data2_Sub1|Data2_Sub2", $Form_Menu_ListView1)
GUICtrlCreateListViewItem("DataN|DataN_SubN|DataN_SubN", $Form_Menu_ListView1)

;The data that appear in the listview be saved in a file like that :

#cs

Data1|Data1_Sub1|Data1_Sub2
Data2|Data2_Sub1|Data2_Sub2
DataN|DataN_SubN|DataN_SubN

#ce

GUISetState(@SW_SHOW, $Form_Menu)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by Slipk
Posted (edited)

The way i would do it is with a loop to go trough all items, and read them,

and write the result to an ini inserting a separating character or string between the column values read,

that can later be used as a separator to populate the listview in the future.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
54 minutes ago, Slipk said:

Hello everybody,

Sorry for my bad english.

 

I try to figure out if I have a dynamic listview with as many items as I want, how to save to a text file all the data listview contains in the same form that you put when you create a listviewitem. I will give you an example.

When the script is running it will show you the listview and some items. How to take the items data "Data1|Data1_Sub1|Data1_Sub2" in this format and paste into a text file? All of them.

I tried to explain as good as I can.

Thank you for your attention!

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

$Form_Menu = GUICreate("Form Example", 351, 234, -1, -1)

$Form_Menu_ListView1 = GUICtrlCreateListView("Column #1|Column #2|Column #3", 0, 0, 346, 230)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)

GUICtrlCreateListViewItem("Data1|Data1_Sub1|Data1_Sub2", $Form_Menu_ListView1)
GUICtrlCreateListViewItem("Data2|Data2_Sub1|Data2_Sub2", $Form_Menu_ListView1)
GUICtrlCreateListViewItem("DataN|DataN_SubN|DataN_SubN", $Form_Menu_ListView1)

;The data that appear in the listview be saved in a file like that :

#cs

Data1|Data1_Sub1|Data1_Sub2
Data2|Data2_Sub1|Data2_Sub2
DataN|DataN_SubN|DataN_SubN

#ce

GUISetState(@SW_SHOW, $Form_Menu)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Try this code:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GuiListView.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$ListView1 = GUICtrlCreateListView("one|two|three", 104, 30, 433, 193)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
For $i = 0 To 50 Step 1
    _GUICtrlListView_AddItem ( $ListView1, $i )
    _GUICtrlListView_AddSubItem ( $ListView1, $i, "sdfdsfsdf", 1 )
    _GUICtrlListView_AddSubItem ( $ListView1, $i, "jjklllllhgdfgfdzgsgsgsgs", 2 )
Next
$Button1 = GUICtrlCreateButton("Click me", 224, 352, 97, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            $columns = _GUICtrlListView_GetColumnCount ( $ListView1 )
            $allitems = _GUICtrlListView_GetItemCount ( $ListView1 )
            $file = FileOpen ( @DesktopDir & "\listviewtext.txt", 2 )
            For $i = 0 To $allitems - 1 Step 1
                $text = _GUICtrlListView_GetItemTextArray ( $ListView1, $i )
                $string = ""
                For $t = 1 To $text[0] Step 1
                    $string = $string & $text[$t] & "|"
                Next
                FileWriteLine ( $file, StringTrimRight ( $string, 1 ) )
            Next
            FileClose ( $file )
    EndSwitch
WEnd

 

  • Moderators
Posted

Slipk,

if you use my GUIListViewEx UDF (as I have already suggested) you will find the _GUIListViewEx_Save/LoadListView functions which do exactly as you wish.

M23

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

Open spoiler to see 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

 

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
×
×
  • Create New...