Jump to content

Menu recreation question


Recommended Posts

Below is a screenshot of M$'s word.

Its in the settings.

What i need is to be able to recreate the 2 list-boxes(or what they are called), the move up/move down buttons and the add/remove button.

Posted Image

My plan is to create a script that fetches all the files in a specific folder.

Then presents them in the left window and the user selects wich he/her wants to print.

Also, is it possible to have a spilted tabel on the right ?

So i can have:

1|file.something

2|hey.document

3|notprintable.hey

etc.

But firstly i need to know if its even possible to recreate the funcionallity.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

possible to recreate the funcionallity

In my opinion: not trivial, but quite possible. :huh2:

I would suggest using ListViews - the GUIListViewEx UDF in my sig will allow the up/down buttons work without problem. I see little difficulty in the swap code - the UDF again allows for insertion and removal of items on a simple button press and adding a bit of code to read the currently selected item is not too difficult.

is it possible to have a spilted tabel on the right ?

Not sure I understand what you want here - but you can have ListViews with multiple columns, so you could have numbers associated with each row. :alien:

Give it a go and see how you get on - you know where we are if you run into difficulties. ;)

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

Thanks! Thats exactly what i wanted!

And multiple columns!

Double thanks!

I know everything i need to know to start.

Ill post back in a bit!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Now, i got the pice of code below and it works as perfect as it can be.

But i do not understand fully how to use this with your UDF.

I tried to rewrite example 1 but do i need to use 2d arrays ?

Could you/someone explain how to put the values you get at the end to use ?

#include <Array.au3>

Global $Array[1]

$FileDialog = FileOpenDialog("", @DesktopDir & "\", "Files (*.*)", 1 + 4 )

FileChangeDir($FileDialog)

$Search = FileFindFirstFile("*.*")

While 1
$File = FileFindNextFile($search)

If @error Then
    _ArrayDisplay($Array)
    Exit
EndIf

$Type = StringRight($File, 4)

$FileTrimmed = StringTrimRight ($File, 4)

If $Type = ".Au3" then
    _ArrayAdd($Array,$FileTrimmed)
EndIf

Wend

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

Why do you not use _FileListToArray to replace the code you have above? It is much easier. :alien:

And how can you use that code with my UDF? You need ListViews, as the name of the UDF suggests, and I see no ListViews there. :huh2:

Let me see if I can rustle up something as an example later on. :ph34r:

M23

Edit:

A working example of how you might do what you want: ;)

#include <GUIConstantsEx.au3>
#include <File.au3>

#include "GUIListViewEx.au3"

Global $aFileList = _FileListToArray("C:\Program Files\AutoIt3\Include", "*.au3", 1)
Global $aAddedList[1] = [0]

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

$hLV_1 = GUICtrlCreateListView(" ", 10, 10, 280, 480, BitOr($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hLV_1h = GUICtrlGetHandle($hLV_1)
_GUICtrlListView_SetExtendedListViewStyle($hLV_1h, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hLV_1h, 0, 255)
For $i = 1 To $aFileList[0]
    GUICtrlCreateListViewItem($aFileList[$i], $hLV_1)
Next
$iLV_1_Index = _GUIListViewEx_Init($hLV_1, $aFileList)

$hLV_2 = GUICtrlCreateListView(" ", 410, 10, 280, 480, BitOr($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hLV_2h = GUICtrlGetHandle($hLV_2)
_GUICtrlListView_SetExtendedListViewStyle($hLV_2h, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hLV_2h, 0, 255)
$iLV_2_Index = _GUIListViewEx_Init($hLV_2h, $aAddedList, 1)

$hButton_1To2 = GUICtrlCreateButton("--->", 300, 215, 80, 30)
$hButton_2To1 = GUICtrlCreateButton("<---", 300, 255, 80, 30)

$hButton_Up = GUICtrlCreateButton("Up", 700, 215, 80, 30)
$hButton_Down = GUICtrlCreateButton("Down", 700, 255, 80, 30)

GUISetState()

_GUIListViewEx_SetActive($iLV_1_Index)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1To2
            $sItem = _GUICtrlListView_GetItemText($hLV_1h, _GUICtrlListView_GetSelectedIndices($hLV_1h))
            ConsoleWrite($sItem & @CRLF)
            _GUIListViewEx_SetActive($iLV_1_Index)
            _GUIListViewEx_Delete()
            _GUIListViewEx_SetActive($iLV_2_Index)
            _GUIListViewEx_Insert($sItem)
        Case $hButton_2To1
            $sItem = _GUICtrlListView_GetItemText($hLV_2h, _GUICtrlListView_GetSelectedIndices($hLV_2h))
            ConsoleWrite($sItem & @CRLF)
            _GUIListViewEx_SetActive($iLV_2_Index)
            _GUIListViewEx_Delete()
            _GUIListViewEx_SetActive($iLV_1_Index)
            _GUIListViewEx_Insert($sItem)
        Case $hButton_Up
            _GUIListViewEx_SetActive($iLV_2_Index)
            _GUIListViewEx_Up()
        Case $hButton_Down
            _GUIListViewEx_SetActive($iLV_2_Index)
            _GUIListViewEx_Down()
    EndSwitch

WEnd

Now over to you to finish it. :)

M23

Edited by Melba23

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

Let me just clearify:

Your udf is a listview add on, not a replacement ?

Also is it possible to navigate with the list views?

Because what i want to print in the end are stickers.

These stickers are located in different folders, wich is located within 4 different folders, wich is on the desktop.

I could use a FileDialog, but i dont whant that.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

Let me just clearify: Your udf is a listview add on, not a replacement ?

Correct. :huh2:

From the first post of the UDF thread:

"The UDF is pretty easy to use:

- You start by creating a ListView (either native or UDF) and passing the returned ControlID/handle and the array you used to fill it to the _Init function of the UDF."

Also is it possible to navigate with the list views?

What do you mean? Navigate how? ;)

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

I got an idea on how to navigate.

What i mean is:

You get folders and files in the list viev then if you click a file you can move it to the other listview.

If you click a directory it will open that directory as Listview 1.

Then just have a home button.

My idea was something like this(its a rough... sketch ? ):

Global $aHomeFileList = _FileListToArray("The directory", "*.au3", 1)
Global $aHomeDirList = ;Here you put a folder finding function

Global $aFileList = _FileListToArray("The directory", "*.au3", 1)
Global $aDirList = ;Here you put a folder finding function

Func _ListUpdate()
For $i = 1 To $aFileList[0]
    GUICtrlCreateListViewItem($aDirList[$i], $hLV_1)
Next

For $i = 1 To $aDirList[0]
    GUICtrlCreateListViewItem($aFileList[$i], $hLV_1)
Next
EndFunc

Func _ListHomeUpdate()
For $i = 1 To $aHomeFileList[0]
    GUICtrlCreateListViewItem($aHomeDirList[$i], $hLV_1)
Next

For $i = 1 To $aHomeDirList[0]
    GUICtrlCreateListViewItem($aHomeFileList[$i], $hLV_1)
Next
EndFunc

Func _ListCleaner()
    Do
        _GUIListViewEx_Delete()
    Until ;Listview is empty
    
    _ListUpdate()
EndFunc

_ListUpdate()

While 1
If *A directory is clicked* Then _ListCleaner()

Select
    Case $HomeButton
        _ListCleaner()
        
EndSelect
WEnd
Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

If you want a folder tree than ListViews are not the way to go. Take a look at my ChooseFileFolder UDF - that will give you a treeview with the folder structure from which you can choose single or multiple files. You will not be able to use the UDF as it is - you will have to adjust the dialog presentation to get the layout you want, but the basic functionality is in there. :huh2:

Getting the selected files into the ListView on the right-hand side of your dialog can be done with the GUIListViewEx UDF as I have already shown. :alien:

Take a look and see how you get on combining the two - if you make a start I will be happy to assist. ;)

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

  • Moderators

Maffe811,

Looking again at the code in the ChooseFileFolder UDF, I can see that combining it into your script would be quite difficult unless you know what is going on - but fortunately I do! :D

So I have produced a "mini" version of the ChooseFileFolder UDF for you to use. Just save this as Foldertree.au3 and put it in the same folder as your script:

#include-once

#include <RecFileListToArray.au3>

Func _FolderTree_Create($iLeft, $iTop, $iWidth, $iHeight, $sRoot = @ScriptDir, $sFile_Mask = "*.*")

    Local $aLevel[100], $iLevel, $aFileList, $sFolderName, $sFileName, $fFolder
    Local $fFilesFound = False
    Local $fFileInFolder = False
    Local $fFileInBranch = False
    Local $iFolderLevel = 0

    Local $hTreeView = GUICtrlCreateTreeView($iLeft, $iTop, $iWidth, $iHeight, BitOr(0x00000037, 0x00800000)) ; $GUI_SS_DEFAULT_TREEVIEW, $WS_BORDER
    GUICtrlSetState(-1, 32) ; $GUI_HIDE

    ; Force trailing \
    If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\"
    ; Create folder array
    $aFileList = _RecFileListToArray($sRoot, $sFile_Mask, 0, 1, 1, 1, "", "$*;System Volume Information;RECYCLED;_Restore")

    If Not @error Then
        ; Strip empty folders and destroy array if no files found
        StringReplace($aFileList[$aFileList[0]], "\", "")
        Local $iLastFolderLevel = @extended
        ; Move through array and blank empty folders
        For $i = $aFileList[0] To 1 Step -1
            ; Check if element is a folder
            If StringRight($aFileList[$i], 1) = "\" Then
                ; If folder then get level
                StringReplace($aFileList[$i], "\", "")
                $iFolderLevel = @extended
                ; Are there files within
                If $fFileInFolder Then
                    ; If so then leave
                    $iLastFolderLevel = $iFolderLevel
                    $fFileInFolder = False
                    ContinueLoop
                EndIf
                ; Look at folder level
                Select
                    Case $iFolderLevel < $iLastFolderLevel
                        ; Have files been found in this branch
                        If $fFileInBranch Then
                            ; Leave if so
                            $iLastFolderLevel = $iFolderLevel
                        Else
                            ; Delete if not
                            $aFileList[$i] = ""
                        EndIf
                    Case $iFolderLevel = $iLastFolderLevel
                        ; Folder is empty and can be deleted
                        $aFileList[$i] = ""
                    Case $iFolderLevel > $iLastFolderLevel
                        ; Clear branch flag
                        $fFileInBranch = False
                        ; Check if any files in the folder
                        If Not $fFileInFolder Then
                            ; Delete as empty folder
                            $aFileList[$i] = ""
                        EndIf
                EndSelect
            Else
                ; If file then set flags
                $fFilesFound = True
                $fFileInFolder = True
                $fFileInBranch = True
            EndIf
        Next
        ; If no files to display destroy array
        If Not $fFilesFound Then $aFileList = 0
    EndIf

    ; Check valid array to load
    If IsArray($aFileList) Then
        ; Set TV ControlID
        $aLevel[0] = $hTreeView
        ; Add remaining folders and files
        For $i = 1 To $aFileList[0]
            ; If blank then ignore
            If $aFileList[$i] = "" Then ContinueLoop
            ; Examine current return
            StringReplace($aFileList[$i], "\", "")
            $iLevel = @extended
            $fFolder = True
            If StringRight($aFileList[$i], 1) <> "\" Then
                $fFolder = False
            EndIf
            ; Display current element
            If $fFolder = True Then ; Folder
                ; Extract folder name from path
                $sFolderName = StringRegExpReplace($aFileList[$i], "(.*\\|^)(.*)\\", "$2")
                ; Add to TV and store item ControlID
                $aLevel[$iLevel] = GUICtrlCreateTreeViewItem($sFolderName, $aLevel[$iLevel - 1])
            Else ; File
                $sFileName = StringRegExpReplace($aFileList[$i], "^.*\\", "")
                GUICtrlCreateTreeViewItem($sFileName, $aLevel[$iLevel])
            EndIf
        Next
    EndIf

    GUICtrlSetState($hTreeView, 16) ; $GUI_SHOW

    Return $hTreeView

EndFunc

You will also need to download the RecFileListToArray UDF from my sig and put it in the folder as well. ;)

Then you can call the function from within your main script like this to load the folder tree - just change the values for $sRoot and $sFile_Mask to those you require: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>

#include "GUIListViewEx.au3"

#include "FolderTree.au3"

Global $aAddedList[1] = [0], $sRoot = @ScriptDir, $sFile_Mask = "*.*"

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

; Create TV and hide
$hTreeView = _FolderTree_Create(10, 10, 280, 480, $sRoot, $sFile_Mask) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$hTreeView_Handle = GUICtrlGetHandle($hTreeView)

$hListView = GUICtrlCreateListView(" ", 410, 10, 280, 480, BitOR($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hListViewh = GUICtrlGetHandle($hListView)
_GUICtrlListView_SetExtendedListViewStyle($hListViewh, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListViewh, 0, 255)
$iListView_Index = _GUIListViewEx_Init($hListViewh, $aAddedList, 1)

$hButton_Transfer = GUICtrlCreateButton("--->", 300, 215, 80, 30)
$hButton_Delete = GUICtrlCreateButton("<---", 300, 255, 80, 30)

$hButton_Up = GUICtrlCreateButton("Up", 700, 215, 80, 30)
$hButton_Down = GUICtrlCreateButton("Down", 700, 255, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_Transfer
            GUICtrlSetState($hTreeView, $GUI_FOCUS)
            $sText = _GUICtrlTreeView_GetText($hTreeView_Handle, _GUICtrlTreeView_GetSelection($hTreeView_Handle))
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Insert($sText)
        Case $hButton_Delete
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Delete()
        Case $hButton_Up
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Up()
        Case $hButton_Down
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Down()
    EndSwitch

WEnd

And you have what I think you wanted - a folder tree from which you can pick files to add to the ListView and then order as you wish. ;)

Is that enough to let you progress? :D

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

This is great!

This is... just... GREAT!!! AWESOME!!! Running out of words!

Thank you, sir!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

My pleasure! :)

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

The point, as stated in the first post, is to prin these files eventually.

So my idea was to put the list views in an array and then automate the printing process with a function and a variable that runs trough all the arrays.

I have to issues doing that:

1. I dont know how to figure out when the ListView is empty so i can stop the function

2. I need the file path for the printing function, but i still need the Foldertree to show the names only.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

Andreik has given you a good tip for the count. :)

To get the full path you need to change the [--->] button Case to read: ;)

Case $hButton_Transfer
    GUICtrlSetState($hTreeView, $GUI_FOCUS)
    ; Force trailing \
    If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\"
    ; Get full path of selected item
    $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTreeView_Handle, 0), "|", "\")
    ; Check it is file
    If Not StringInStr(FileGetAttrib($sRoot & $sSelectedPath), "D") Then
        _GUIListViewEx_SetActive($iListView_Index)
        _GUIListViewEx_Insert($sRoot & $sSelectedPath)
    EndIf

You now get the full path in the ListView. ;)

Are you done yet or do you want even more? :D

M23

Edit: Typnig!

Edited by Melba23

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

This is probably all i need, but i dont want the file path in the listview, but in the array that comes when you click confirm.

But im gonna try to fix that myself with the help i have gotten!

Thank you both!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

1. I dont know how to figure out when the ListView is empty so i can stop the function

This was easy thanks to Andreik!

Thanks! :)

2. I need the file path for the printing function, but i still need the Foldertree to show the names only.

This is now functional the way i want to... except if i have:

Test1.txt

Test2.txt

Test3.txt

In the list it will present this in the array:

Test3.txt

Test3.txt

Test3.txt

It will add the last entry times how many entries you had...

I cant figure out a way to do make _ListToArray() work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
#include "FolderTree.au3"
#Include <GuiListView.au3>



Global $aArray[1], $i, $Test = 0

Func _ListToArray()
    Do
    ; Force trailing \
        If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\"
        ; Get full path of selected item
        $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTreeView_Handle, 0), "|", "\")
        ; Check it is file
        _ArrayAdd($aArray, $sRoot & $sSelectedPath)
        MsgBox("","",$sRoot & $sSelectedPath)
        _GUIListViewEx_Delete()
    Until _GUICtrlListView_GetItemCount($hListViewh) = 0
    _ArrayDisplay($aArray)
    Exit
EndFunc


Global $aAddedList[1] = [0], $sRoot = @DesktopDir & "\Test", $sFile_Mask = "*.txt"

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

; Create TV and hide
$hTreeView = _FolderTree_Create(10, 10, 280, 480, $sRoot, $sFile_Mask) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$hTreeView_Handle = GUICtrlGetHandle($hTreeView)

$hListView = GUICtrlCreateListView(" ", 410, 10, 280, 480, BitOR($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hListViewh = GUICtrlGetHandle($hListView)
_GUICtrlListView_SetExtendedListViewStyle($hListViewh, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListViewh, 0, 255)
$iListView_Index = _GUIListViewEx_Init($hListViewh, $aAddedList, 1)

$hButton_Transfer = GUICtrlCreateButton("--->", 300, 215, 80, 30)
$hButton_Delete = GUICtrlCreateButton("<---", 300, 255, 80, 30)

$hButton_Up = GUICtrlCreateButton("Up", 700, 215, 80, 30)
$hButton_Down = GUICtrlCreateButton("Down", 700, 255, 80, 30)

$hButton_Confirm = GUICtrlCreateButton("Confirm", 700, 460, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
            Exit
    Case $hButton_Transfer
            GUICtrlSetState($hTreeView, $GUI_FOCUS)
            $sText = _GUICtrlTreeView_GetText($hTreeView_Handle, _GUICtrlTreeView_GetSelection($hTreeView_Handle))
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Insert($sText)
    Case $hButton_Delete
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Delete()
        Case $hButton_Up
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Up()
        Case $hButton_Down
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Down()
    Case $hButton_Confirm
        _ListToArray()
    EndSwitch
WEnd

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Moderators

Maffe811,

Last bit of help for a while. :D

As to your second problem, you were only ever reading the currently selected item in the ListView - which is why you always got the last entered item. But there is a way to do it..... ;)

If you create the ListView with 2 columns but make the second invisible, you can store 2 items in the ListView but only see one! :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
#include "FolderTree.au3"
#Include <GuiListView.au3>

#include <Array.au3>

Global $aArray[1], $i, $Test = 0

Global $sRoot = @ScriptDir, $sFile_Mask = "*.*"

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

; Create TV and hide
$hTreeView = _FolderTree_Create(10, 10, 280, 480, $sRoot, $sFile_Mask)
$hTreeView_Handle = GUICtrlGetHandle($hTreeView)

$hListView = GUICtrlCreateListView(" | ", 410, 10, 280, 480, BitOR($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hListViewh = GUICtrlGetHandle($hListView)
_GUICtrlListView_SetExtendedListViewStyle($hListViewh, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListViewh, 0, 255)
_GUICtrlListView_SetColumnWidth($hListViewh, 1, 1) ; make second column invisible <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iListView_Index = _GUIListViewEx_Init($hListViewh, "", 1)

$hButton_Transfer = GUICtrlCreateButton("--->", 300, 215, 80, 30)
$hButton_Delete = GUICtrlCreateButton("<---", 300, 255, 80, 30)

$hButton_Up = GUICtrlCreateButton("Up", 700, 215, 80, 30)
$hButton_Down = GUICtrlCreateButton("Down", 700, 255, 80, 30)

$hButton_Confirm = GUICtrlCreateButton("Confirm", 700, 460, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
            Exit
    Case $hButton_Transfer
            GUICtrlSetState($hTreeView, $GUI_FOCUS)
            ; Force trailing \
            If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\"
            ; Get full path of selected item
            $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTreeView_Handle, 0), "|", "\")
            ; Check it is file
            If Not StringInStr(FileGetAttrib($sRoot & $sSelectedPath), "D") Then
                ; Extract the file name from the path
                $sFile = StringRegExpReplace($sSelectedPath, "^.*\\", "")
                _GUIListViewEx_SetActive($iListView_Index)
                ; Insert both the file name and the fullpath into the array <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                ; Because the ListView has only 1 visible column, only the filename is displayed - the full path is hidden
                Global $aData[2] = [$sFile, $sRoot & $sSelectedPath]
                _GUIListViewEx_Insert($aData)
            EndIf
    Case $hButton_Delete
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Delete()
        Case $hButton_Up
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Up()
        Case $hButton_Down
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Down()
    Case $hButton_Confirm
        _ListToArray()
    EndSwitch
WEnd

Func _ListToArray()

    ; Get the full array of the ListView contents from the GUIListViewEx UDF
    $aList = _GUIListViewEx_Return_Array($iListView_Index)
    ; But now you can see the second element with the full path <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _ArrayDisplay($aList)

EndFunc

Happy now? ;)

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

Thank you!

You, sir, are a genius!

The hidden listview thing was brilliant...

I was starting to think i was getting good.

Turns out, im justt starting to become decent :)

Im so happy right now! ;)

This was all i needed! Thank you!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

This wasnt all i needed :)

I cant understand what i have to do to remove the extention in the folderview.

I changed a bit in the $hButton_Transfer, but that only removes the extention in the Listview.(wich i expected)

But how can i remove the extention all along for the Presented file names, while the full path stays with extention?

Code so far, with notepad for testing.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
#include "FolderTree.au3"
#Include <GuiListView.au3>
#include <Array.au3>

;Variables
Global $aArray[1], $i, $Test = 0, $hGUI, $hTreeView, $hTreeView_Handle, $hListView, $hListViewh, $iListView_Index
Global $hButton_Transfer, $hButton_Delete, $hButton_Up, $hButton_Down, $hButton_Confirm, $sSelectedPath, $sFile, $sFile1, $aList

#Region///Settings///
;Where it will look for files:
Global $sRoot = @DesktopDir
;The file extention:
Global $sFile_Mask = "*.txt"
#Endregion///Settings///

;Gui creation
$hGUI = GUICreate("Test", 680, 500)

; Create TreeView and hide
$hTreeView = _FolderTree_Create(10, 10, 280, 480, $sRoot, $sFile_Mask)
$hTreeView_Handle = GUICtrlGetHandle($hTreeView)


;Create ListView
$hListView = GUICtrlCreateListView(" | ", 390, 10, 280, 480, BitOR($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL))
$hListViewh = GUICtrlGetHandle($hListView)
_GUICtrlListView_SetExtendedListViewStyle($hListViewh, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListViewh, 0, 255)
_GUICtrlListView_SetColumnWidth($hListViewh, 1, 1) ; make second column invisible <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iListView_Index = _GUIListViewEx_Init($hListViewh, "", 1)

;Buttons
$hButton_Transfer = GUICtrlCreateButton("--->", 300, 150, 80, 30)
$hButton_Delete = GUICtrlCreateButton("<---", 300, 185, 80, 30)
$hButton_Up = GUICtrlCreateButton("Up", 300, 220, 80, 30)
$hButton_Down = GUICtrlCreateButton("Down", 300, 255, 80, 30)
$hButton_Confirm = GUICtrlCreateButton("Confirm", 300, 460, 80, 30)

;Show Gui
GUISetState()

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
            Exit
    Case $hButton_Transfer
            GUICtrlSetState($hTreeView, $GUI_FOCUS)
            ; Force trailing \
            If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\"
            ; Get full path of selected item
            $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTreeView_Handle, 0), "|", "\")
            ; Check it is file
            If Not StringInStr(FileGetAttrib($sRoot & $sSelectedPath), "D") Then
                ; Extract the file name from the path
                $sFile = StringRegExpReplace($sSelectedPath, "^.*\\", "")
                _GUIListViewEx_SetActive($iListView_Index)
                $sFile1 = StringTrimRight ($sFile, 4)
                ; Insert both the file name and the fullpath into the array <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                ; Because the ListView has only 1 visible column, only the filename is displayed - the full path is hidden
                Global $aData[2] = [$sFile1, $sRoot & $sSelectedPath]
                _GUIListViewEx_Insert($aData)
            EndIf
    Case $hButton_Delete
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Delete()
        Case $hButton_Up
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Up()
        Case $hButton_Down
            _GUIListViewEx_SetActive($iListView_Index)
            _GUIListViewEx_Down()
    Case $hButton_Confirm
            _ListToArray()
    EndSwitch
WEnd

Func _ListToArray()
    GUISetState(@SW_HIDE)
    ; Get the full array of the ListView contents from the GUIListViewEx UDF
    $aList = _GUIListViewEx_Return_Array($iListView_Index)
    ; But now you can see the second element with the full path <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;~     _ArrayDisplay($aList)

    $i = 1
    Do
#Region ///Print function///
        ShellExecute($aList[$i][1])
        Sleep(800)
        Send("Test")
        Sleep(200)
        Send("^p")
        Sleep(1000)
        Send("{ESC}")
        Send("!{F4}")
        Sleep(500)
        Send("i")
        Sleep(1000)
#EndRegion ///Print function///
    ;Add 1 to $i
    $i += 1
    Until $i = $aList[0][0] + 1
Exit
EndFunc

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

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...