Slipk Posted January 26, 2019 Posted January 26, 2019 (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 January 26, 2019 by Slipk
careca Posted January 26, 2019 Posted January 26, 2019 (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 January 26, 2019 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
MattHiggs Posted January 26, 2019 Posted January 26, 2019 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: expandcollapse popup#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 Slipk 1
dmob Posted January 26, 2019 Posted January 26, 2019 Guiness wrote a similar function a while back: Slipk 1
Moderators Melba23 Posted January 26, 2019 Moderators Posted January 26, 2019 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 Slipk 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now