Jump to content

Code Help [Solved]


Negro
 Share

Recommended Posts

How to list specific files in the extensions folder and copy it to another folder?

for example :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>
Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"
$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)
$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)
GUISetState(@SW_SHOW, $Gui)
While 1
    Sleep(100)
WEnd
Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "\" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc
Func FindDesktopFiles($sType = "All Types")
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))
    Local $ext = "*." & $sType, $FL2A
    If $sType = "All Types" Then $ext = "*.*"
    $FL2A = _FileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            If $sType = "All Types" Then
                Local $SST = StringSplit($fTypes, "|")
                For $j = 1 To $SST[0]
                    If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                            GUICtrlCreateListViewItem($FL2A[$i], $LV)
                Next
            ElseIf $sType <> "All Types" Then
                If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                        GUICtrlCreateListViewItem($FL2A[$i], $LV)
            EndIf
        Next
        _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf
EndFunc
Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Link to comment
Share on other sites

  • Moderators

Negro,

If you want to search for files with multiple extensions, look at the RecFileListToArray UDF in my sig. :)

If that is not what you are looking for, can you please explain more clearly. ;)

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

Listing extensions with your function [RecFileListToArray UDF]

As the above example

how do make it ?

My English is not good :)

Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Link to comment
Share on other sites

  • Moderators

Negro,

Have you looked at the thread and the function header? ;)

Here is an example:

#include <Array.au3>
#include "RecFileListToArray.au3"

; Search for files with .sys and .dll extensions only
$aList = _RecFileListToArray("C:\Windows\System32\", "*.sys;*.dll", 1)

_ArrayDisplay($aList)

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

Are you looking for something more like this? Quick pseudo-code, of course needs further work.

$sTargetFolder = FileSelectFolder()
For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
    if _GUICtrlListView_GetItemChecked($LV, $s) Then
        FileCopy(@DesktopDir & "" & _GUICtrlListView_GetItemText(),$sTargetFolder)
    endif
Next
Link to comment
Share on other sites

  • Moderators

Negro,

Try this: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

#include "RecFileListToArray.au3" ; You need this <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))

    Switch $sType
        Case "All Types"
            $ext = "*.au3;*.doc;*.docx;*.txt;*.zip;*.rar;*.lnk" ; Multiple extensions <<<<<<<<<<<<<<
        Case Else
            $ext = "*." & $sType ; Single extension <<<<<<<<<<<<<<<<<<<<
    EndSwitch

    $FL2A = _RecFileListToArray(@DesktopDir, $ext, 1) ; Search here <<<<<<<<<<<<<<<<<<<<<<<<<<
    If Not @error Then
        For $i = 1 To $FL2A[0]
            GUICtrlCreateListViewItem($FL2A[$i], $LV)
        Next
         _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf

EndFunc

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

KaFu,

Yes As in the picture above. ;)

$sTargetFolder = FileSelectFolder()
For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
    if _GUICtrlListView_GetItemChecked($LV, $s) Then
        FileCopy(@DesktopDir & "" & _GUICtrlListView_GetItemText(),$sTargetFolder)
    endif
Next

:)FileRecycle(@DesktopDir&""&_GUICtrlListView_GetItemText($LV,$s, 0))

I would like to improve the way you say

Melba23,

I think you, understand me :D

but do not delete files

Copy the files where I want :)

As kaFu says, I want to do.

Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Link to comment
Share on other sites

  • Moderators

Negro,

Sie wurden sehr faul überall, so können Sie herausfinden, was geändert wurde. :)

Trans: You have been very lazy throughout, so you can work out what has been changed.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

#include "RecFileListToArray.au3"

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$CopyTo = GUICtrlCreateButton("Move Selected File(s)", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $CopyTo
            $sDest = FileSelectFolder("Select Destination Folder", "")
            If $sDest Then
                For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                    If _GUICtrlListView_GetItemChecked($LV, $s) Then
                        FileMove(@DesktopDir & "" & _GUICtrlListView_GetItemText($LV, $s, 0), $sDest & "")
                    EndIf
                Next
                FindDesktopFiles(GUICtrlRead($Combo))
            EndIf
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))

    Switch $sType
        Case "All Types"
            $ext = "*.au3;*.doc;*.docx;*.txt;*.zip;*.rar;*.lnk"
        Case Else
            $ext = "*." & $sType
    EndSwitch

    $FL2A = _RecFileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            GUICtrlCreateListViewItem($FL2A[$i], $LV)
        Next
         _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf

EndFunc

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

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