Jump to content

New project - Move Directories and Create New destination


Recommended Posts

Ok this is going to be my second Autoit script project. The first one I did was which Melba23 was instrumental in my successful completion of it.

Programming is not something I do on a regular basis. I have done it in the past so the concepts are familiar to me but fleshing out a new project like this is not. I have some time on my hands now as I am unemployed and looking for a new job. Things are scarce in my town but am sure I will find something shortly.

I saw in her sig a UDF she created and it gave me an idea for another script.

As you could tell from my previous script it was based on video files. Well now I want to organize them in my media drive and directories. Commercial video library apps just don't appeal to me and sure windows file explorer can do this as well but this seems more fun to create and would be more useful in the long run as it will allow me to apply it to other directories on my system.

So what I thought I could do was create a script that would read all the directories in my holding directory allow me to select some click a button to create a directory in my main storage directory then move those files to the created directory. Now if the directory does exist in my storage directory I just need to select it as the destination directory and do a directory move.

Now this is going to be a very advanced script for me as it will have to be a GUI script which is all brand new to me.

So my thought was to use ChooseFileFolder UDF 2x's in this script. One for the source and one for the destination. With the destination one I can have a button that will allow me to create the destination directory if needed or then just select it and hit the move button to move the directory. Now the sources will all be directories with files in them.

Now as an added feature that I would like to add if possible launching my media player to view the video file briefly and if I want to keep it then move it if not then delete the directory.

So the above is the basic structure of the script. Now if I am reinventing the wheel here with this so be it. Granted explorer can do this pretty easily but this will be laid out easier for me and button pushing makes things easier.

So I guess what this post is about is to get an idea of how to get started, What I need to look at, and what I need to learn. I hope with this project I have not bitten off more then I can chew. I have not fleshed out any code yet. I did run Melba23's example scripts and saw from them that this could be possible with using it. Again I may have bit off more then I can chew and may have to start off with something simpler then move on to this.

Link to comment
Share on other sites

  • Moderators

sparker366,

Less of the "her" please - I have a perfectly serviceable "Y" chromosome! ;)

M23

Edited by Melba23
Typo

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

 

Link to comment
Share on other sites

  • Moderators

sparker366,

No problem - you are not the first and probably not the last to make that mistake. Serve me right for choosing an old radio call-sign as my nick when I first joined the forum. :D

an idea of how to get started

You say you know very little about GUIs - so start by creating a few and seeing how they are coded and how the different styles affect the result. Add some controls and see how they react to user input - there is little point in controls that do nothing or cannto be actioned. Then you can think about your project GUI - what controls are needed, where are they positioned, what text do you require to label the various elements. There is a GUI creation tool Koda which you might find helpful (I do not use it myself but others quite like it) - look under the SciTE <Tools> menu.

But before you finalise the design of your GUI, have a think about what you want the script to do. I find it helpful to write out the program logic in ever more detailed pseudo-code like this (this is not for your project of course):

Display the possible files
    Read ini file to get list
    Add list to combo
Read content of selected file
    Convert to suitable format for list
Display content in list control
Read selected item in list when button pressed
Do something with this item
etc, etc, etc

You can break down this pseudo-code into smaller and smaller sections until you know how to do each item - then you have the basis of what you need to do to achieve your goal. As you suggested in your other thread you can write small scripts to learn how to code each section if you have not done it before - then you know that adding a new section is unlikely to break what you already have.

I hope that is good enough to get you started. :)

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

 

Link to comment
Share on other sites

Ok I did some thinking about this project yesterday. I didn't work on anything as had other things to do but wrote some notes on it.

Below are the notes. I am using music as my example but this can apply to anything.

A: Starting folder will be a path inputed via an input box
    A1: D:\Incoming\music
B: Source can be multiple folders in the parent folder. Each folder is artist name - album name
    B1: D:\incoming\Music\REM-Reckoning, D:\incoming\Music\REM-Fables.of.the.Reconstruction, D:\incoming\Music\REM-Green
C: Dest is a static path
    C1: D:\music\
E: Display Source folder in treeview folders only and allow multiple selections
F: Display Dest Folder in treeview allow single selection.
G: Allow creation of sub folder in dest folder tree view then select that created sub folder as the dest folder.
    G1: There is no REM subfolder so create one
    G2: Button under Dest folder treeview to popup an input box to add the sub folder name
H: CFF UDF allows multiple selections delimited by "|"
    H1: Create result array with each indvidual path
    H2: Do this with StringSplit function.
I: Once resultant source array is built do a loop through that array using [0] stored count of paths and move the folders.
J: Reset the controls and do it again[/indent

Now I need to figure out where to start on this. I do need to build this in stages to learn the different concepts of the GUI scripting then combine them into the final project. Looking at the example script for CFF it looks like I can model it off the 4th example in there. I'm going to use _CFF_Embed to accomplish what I need Due to needing 2 treeviews and a folder create button and a folder move button. I know you said there was a program called KODO and that you don't use that. Well I looked at it an it may assist me in what i need to do with this project.

Hopefully I haven't bitten off more then I can chew with this project.

Edited by sparker366
Link to comment
Share on other sites

  • Moderators

sparker,

Hopefully I haven't bitten off more then I can chew with this project

You will learn a great deal about AutoIt as you work through the various sections, so I doubt any of your effort will be wasted. ;)

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

 

Link to comment
Share on other sites

Ok. The hard part is breaking this down into manageable parts. Since this will be based on using the CFF UDF I need to make that integral in my stages. So first I need to design the GUI. Once that is designed I can pass the handles to the CFF UDF to get that to populate the treeviews and allow the selections of the source folders. Guess I need to make a few source test folders and put a bunch of text files in there and then make a destination folder with existing folders to test the dir move code.

Link to comment
Share on other sites

No need to re-invent the wheel... Download AMT and SMF (see my sig). Create Screencaps (multiple pictures) &amp; Preview Caps (single picture preview, separate checkbox "Create Single Frame Preview Caps", see about tab for an explanation) with AMT. Search the directories with SMF, filter the results on "_PCS." to see only the preview pictures, switch to Icon view, activate the "Rewrite File Location" plugin, set the "Pattern" to "PCS.jpg" and Replace to empty and a double-click on the picture will start the movie with the default media player.

post-40098-0-00788700-1357820459_thumb.j

Edit: Oh, just read that this is not about displaying but putting media files on different folders. Well, AMT + SMF might help you there too by giving you a good overview to manually cut+move the files, but what I've described above of course has nothing to do with the sorting itself but only is a way to have a "Movie Browser" for your final collection.

Edited by KaFu
Link to comment
Share on other sites

Ok I started working on the GUI for this project. I used KODA to design it and code it I am including a pic of it and the code.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\scripts\koda_1.7.3.0\Forms\Move-Files.kxf
Local $Form1 = GUICreate("Move files", 666, 590, 192, 124)
Local $TreeView1 = GUICtrlCreateTreeView(32, 56, 257, 257, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_FULLROWSELECT,$WS_HSCROLL,$WS_VSCROLL))
Local $TreeView2 = GUICtrlCreateTreeView(368, 56, 257, 257, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_FULLROWSELECT,$WS_HSCROLL,$WS_VSCROLL))
Local $List1 = GUICtrlCreateList("", 168, 368, 225, 136, BitOR($GUI_SS_DEFAULT_LIST,$WS_HSCROLL))
Local $Label1 = GUICtrlCreateLabel("Source", 32, 16, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $Label2 = GUICtrlCreateLabel("Destination", 360, 16, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $btn1 = GUICtrlCreateButton("Move", 256, 520, 60, 25)
Local $btn2 = GUICtrlCreateButton("Quit", 336, 520, 60, 25)
Local $Label3 = GUICtrlCreateLabel("Selected files", 216, 336, 147, 20, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $btn3 = GUICtrlCreateButton("Create Dir", 168, 520, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

EndSwitch
WEnd

post-77351-0-73880200-1357892372_thumb.p

I haven't done anything else yet on this as I am first trying to figure out how to read button clicks. The help file is not to clear to me on it. i know something goes in the case statement but not sure what. I am still trying to get more familiar with Melb23's CFF UDF so I can figure out how to implement this form in it. I am working through ChooseFileFolder_Example_2.au3 as that uses the GUI created outside the main script.

Now I need to have both trees active with that UDF as I need to multi select from the source tree and single select from the destination tree and or create a directory.

This is going to be a long project unlike the other one which got completed fairly quickly. GUI's really add a lot of stuff to a project. I did see a Youtube video on it may have to go back and watch that to figure out the button click events. I'll get this. Some hints from the gallery may not be bad.

Edited by sparker366
Link to comment
Share on other sites

  • Moderators

Try something in this format:

While 1
$nMsg = GUIGetMsg()
 Select
  Case $nMsg = $GUI_EVENT_CLOSE
   Exit
  Case $nMsg = $btn1
   ;do stuff
  Case $nMsg = $btn2
   ;do different stuff
 EndSelect
WEnd

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Ok I got the buttons to popup msgbox's so that is step done. Now I am having a hard time understanding the CFF UDF and making it work. I tried to follow the second example script and its not making any sense to me. That second example script is for use with user designed GUI. I just can't follow it.

What if i do this since I am having issues with following the CFF UDF what if I created 3 Listviews an input box Create Dir Button. Move Button and Quit Button. Use the RecFileListToArray UDF to pull all the directories out of my source directory and populate a listview. Then call it again to populate the destination listview. Now I was searching some and saw that you can select multiple rows in a ListView if you use the style $LVS_REPORT" and then you can also show checkboxes with this extended style $LVS_EX_CHECKBOXES. Now where do I go to find out how to cycle through a listview and retrieve the items with a selected checkbox? If I can do that I can either load that in an array and the pass that array to the dirmove function or just loop through the listview keying on the checkboxes checked and grab the path from there and move the directories. Not sure what would be more efficient?

I feel that the CFF UDF would have been a nice way to do this project but the learning curve is just not there for me. Not sure why. I really don't need a treeview like I originally thought I may need. I can accomplish this with listviews and the check boxes and the report style. The list view is only going to be single column as its going to just have the full path and filename. So with that said I am going to mess around with listviews and the checkboxes and seeing if I can get the checked items and display them in a message box.

I have my work cut out for me.

Edited by sparker366
Link to comment
Share on other sites

There are dozens of examples of how to loop through a listview with checkboxes on the forum. You just need to search for them. Use Google if you want something a little better when you're doing your search. Use site:www.autoitscript.com/forum when you google it, so it will search only this forum.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

BrewManNH I did search the forums for that information and came up empty on my first attempt. On my second pass through I got lucky and found a post with some information in it and looked at _GUICtrlListView_GetSelectedIndices.

Well I have made some headway in learning this GUI stuff. I created a GUI for testing listview stuff. I was able to populate it with information from a file. It works and now I am getting familiar with the styles and ext-styles of the GUI controls.

Now I am going to add a button to pop a msgbox up and display the checked items in the listview. What I can't figure out from the help file for _GUICtrlListView_GetSelectedIndices is how to have it return an array instead of a delimited string. The ListView is going to have paths in it. I don't want to add another step by splitting the returned string into an array. If I have to so be it. Its then going to looped through that resultant array and move the directories to the destination directory. I then have to refresh the list view by calling this _GUICtrlListView_DeleteItemsSelected which I hope works with the checkboxes. I don't think it wouldn't as those rows are selected via checkboxes.

Next to play with kodo and see if I can make this GUI abit nicer. I did mess with the listview and made the column huge so it puts the hsroll bar in. The vscroll is auto added due to the size of the information being added.

One last thing. The size of the GUI. Since I am working with 2 listviews and 4-5 buttons and an input box needs to be fairly large. I am at 1920x1080 and since this is only going to be run on my comp can I make the gui like 1200x1200 or even somewhat bigger. I know that may sound like a silly question but since I have never done anything this major before using the GUI I am just curious.

So I am about done for tonight. Will get back at it in the AM. Maybe I can have a semi working script sometime tomorrow?

post-77351-0-36569700-1357892418_thumb.p

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <RecFileListToArray.au3>
#include <File.au3>
#include <Array.au3>
Local $aRecords
Global $logfile = "d:\logs\del2.log"

;Get Test Data from a file
If Not _FileReadToArray($logfile, $aRecords) Then
MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
Exit
EndIf


#Region ### START Koda GUI section ### Form=d:\scripts-programming\koda_1.7.3.0\forms\move-files.kxf
Local $Form1_1 = GUICreate("Move files", 1058, 601, 192, 124)
Local $Label1 = GUICtrlCreateLabel("Source", 112, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $Label2 = GUICtrlCreateLabel("Destination", 696, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $btn1 = GUICtrlCreateButton("Create Dir", 288, 544, 65, 25)
Local $btn2 = GUICtrlCreateButton("Move", 464, 544, 60, 25)
Local $btn3 = GUICtrlCreateButton("Quit", 608, 544, 60, 25)
Local $hListView1 = GUICtrlCreateListView("", 16, 64, 500, 400, BitOR($LVS_REPORT,$LVS_NOCOLUMNHEADER,$LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
Local $hListView2 = GUICtrlCreateListView("", 536, 64, 500, 400, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER))
Local $Input1 = GUICtrlCreateInput("Input1", 336, 480, 329, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Main Script

_GUICtrlListView_InsertColumn($hListView1, 0, "Column 1", 900)
For $i = 1 To $aRecords[0]
_GUICtrlListView_AddItem($hListView1, $aRecords[$i], $i)
Next


While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $btn1
MsgBox(0, "Create", "Create Directories")
Case $nMsg = $btn2
MsgBox(0, "Move", "Move Directories")
Case $nMsg = $btn3
MsgBox(0, "Quit", "Quit")
Exit
EndSelect
WEnd
Edited by sparker366
Link to comment
Share on other sites

Below is my current code for this script. i am having issues getting the selected items in the list. There are 21 directories being returned by _RecFileListToArray, as indicated in the first msgbox. The 1st msgbox in the while loop is not showing any value. When I select items from the list the second msgbox in the while loop is showing 0. However sometimes it will display a number other then 0.

So I am having issues getting the returned selections from the ListView. If I can't get the items selected then there is no way I can move the directories. I have been reading the helpfile very closely and some of the code is taken from there. Unless I am missing something or have to use the _GUICtrlListView_SetItemSelected to set the selected items, which I don't know how to do unless there is an on click event for the ListView that needs to be read. Am I missing a ListView style or extended style that needs to be set? Nothing I have tried seems to return the items selected or the count of the items selected. The array is populated with directories as shown by the msgbox displayed after this statement is run "$aArray = _RecFileListToArray($spath, "*", 2, 1, 1, 2)"

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <RecFileListToArray.au3>
#include <File.au3>
#include <Array.au3>
Local $aRecords
Local $aArray
Global $spath = "d:\Scripts-Programming\"

;Get Test Data
$aArray = _RecFileListToArray($spath, "*", 2, 1, 1, 2)
MsgBox(0, "Result", @error & " " & @extended & " " & $aArray[0])


#region ### START Koda GUI section ### Form=d:\scripts-programming\koda_1.7.3.0\forms\move-files.kxf
Local $Form1_1 = GUICreate("Move files", 1058, 601, 192, 124)
Local $Label1 = GUICtrlCreateLabel("Source", 112, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $Label2 = GUICtrlCreateLabel("Destination", 696, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $btn1 = GUICtrlCreateButton("Create Dir", 288, 544, 65, 25)
Local $btn2 = GUICtrlCreateButton("Move", 440, 544, 60, 25)
Local $btn3 = GUICtrlCreateButton("Quit", 600, 544, 60, 25)
Local $hListView1 = GUICtrlCreateListView("", 16, 64, 500, 400, BitOR($LVS_REPORT, $LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
Local $hListView2 = GUICtrlCreateListView("", 536, 64, 500, 400, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER))
Local $Input1 = GUICtrlCreateInput("Input1", 336, 480, 329, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

;Main Script

_GUICtrlListView_InsertColumn($hListView1, 0, "Path", 900)
If IsArray($aArray) Then
For $i = 1 To $aArray[0]
_GUICtrlListView_AddItem($hListView1, $aArray[$i], $i)
Next
Else
MsgBox(0, "Error", "No Array Created")
EndIf

While 1
$nMsg = GUIGetMsg()
$sSelection = _GUICtrlListView_GetSelectedIndices($hListView1)
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $btn1
MsgBox(4160, "Information", "Selected Indices: " & $sSelection)
MsgBox(4160, "Information", "Selected Count: " & _GUICtrlListView_GetSelectedCount($hListView1))
Case $nMsg = $btn2
MsgBox(0, "Move", "Move Directories")
Case $nMsg = $btn3
MsgBox(0, "Quit", "Quit")
Exit
EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

sparker366,

When you tick the checkbox, you are not "selecting" the item, you are "checking" it - so that is what you have to look for when you check the ListView. :)

This script returns the indices of the items which are checked and the total number - you will have to reset the path you use as I changed it for testing: ;)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <RecFileListToArray.au3>
#include <File.au3>
#include <Array.au3>
Local $aRecords
Local $aArray
Global $spath = "M:\Program" ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;Get Test Data
$aArray = _RecFileListToArray($spath, "*", 2, 1, 1, 2)

Local $Form1_1 = GUICreate("Move files", 1058, 601, 192, 124)
Local $Label1 = GUICtrlCreateLabel("Source", 112, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $Label2 = GUICtrlCreateLabel("Destination", 696, 32, 212, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Local $btn1 = GUICtrlCreateButton("Create Dir", 288, 544, 65, 25)
Local $btn2 = GUICtrlCreateButton("Move", 440, 544, 60, 25)
Local $btn3 = GUICtrlCreateButton("Quit", 600, 544, 60, 25)
Local $hListView1 = GUICtrlCreateListView("", 16, 64, 500, 400, BitOR($LVS_REPORT, $LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
Local $hListView2 = GUICtrlCreateListView("", 536, 64, 500, 400, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER))
Local $Input1 = GUICtrlCreateInput("Input1", 336, 480, 329, 21)
GUISetState(@SW_SHOW)

;Main Script

_GUICtrlListView_InsertColumn($hListView1, 0, "Path", 900)
If IsArray($aArray) Then
    For $i = 1 To $aArray[0]
        _GUICtrlListView_AddItem($hListView1, $aArray[$i], $i)
    Next
Else
    MsgBox(0, "Error", "No Array Created")
EndIf

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $btn1
            $sSelection = ""
            $iCount = 0
            For $iIndex = 0 To $aArray[0] - 1
                If _GUICtrlListView_GetItemChecked($hListView1, $iIndex) Then
                    $sSelection &= "|" & $iIndex
                    $iCount += 1
                EndIf
            Next
            MsgBox(4160, "Information", "Selected Indices: " & $sSelection)
            MsgBox(4160, "Information", "Selected Count: " & $iCount)
        Case $nMsg = $btn2
            MsgBox(0, "Move", "Move Directories")
        Case $nMsg = $btn3
            MsgBox(0, "Quit", "Quit")
            Exit
    EndSelect
WEnd

All clear? :)

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

 

Link to comment
Share on other sites

LOL you know what after I went and laid down I realized I used the wrong method. I was just getting back up to look for checked instead of selected methods and redo my code. Thanks for the reply.

Now how do I get the values returned for the checked items in the ListView? You are just creating a variable with what row numbers were selected in the list view.I how do I get the actual value to display. I have tried to use this _GUICtrlListView_GetItemChecked and it only returns "True" if I run the sample script from the help file for that function. I have poured through the help file looking for a way to display the values of the checked items but I am coming up blank.

I knew that I needed to use checked items instead of selected items once I took a nap and thought on it. You also told me that in your post..

Link to comment
Share on other sites

  • Moderators

sparker366,

The code I posted above determines which ListView items are checked by looping through them and using the item index - why not take a look in the Help file and see if there is a function to get the "text" of a ListView item based on its index? :huh:

If you were to do this you would probably come across _GUICtrlListView_GetItemText - use that function in the loop and you would get a list of the selected paths in $sSelection rather than the indices themselves. ;)

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

 

Link to comment
Share on other sites

Ok I must be brain dead this morning. I have no reason why I didn't think of the "text" aspect of the ListView to get the values I needed. I just thought by getting the checked item that would have the value I wanted.

So yes the _GUICtrlListView_GetItemText does what I need. So now to build that in and build an array so I can loop through that array and move the directories that were checked.

Again not sure why i didn't think about the text attribute of the ListView but again your help has got me moving forward.

Now I would also want to use _GUICtrlListView_GetItemCount so I can use that as the value for the for loop to loop through and get checked items or I could just reuse the count from your UDF I call to populate the ListView. I best use this _GUICtrlListView_GetItemCount to be safe.

Edited by sparker366
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...