Jump to content

Drag N' Drop problem


Recommended Posts

Ok, I've made a program that copies files from one OR many directories into another directory, everything works well except from one feature I'm trying to use, the drag n' drop. Because I've written all the code on my own (excpect from the reduce memory snippet which is floating around) it may not be optimized but it does the job.The drag and drop I added so that when you drop a folder and the another folder it will add the first an then a comma and then the second and so on... That works, the thin is when I click on the drop zone a error occurs cause the @GUI_DRAGFILE isn't valid. Is there any way that @GUI_DRAGFILE can return 0 so I can use a <> 0 If-else and make my program work as I want it to? Or is there some other way to do the drag and drop thin I want?

Here is my code, just run it and click on the drop zone to see, then run it again and try dropping a file...

Something else that doesn't seem ok is that the drop event ens when I click on the drop zone once more...

If I can do what I want directly onto the Input then I'll get rid of the drop zone.(The problem with that was it put the text directly into the input, instead of the comma if I put another folder)

PS1. I use this to copy downloaded files from many directories into specific ones, like .avi -> videos

PS2. The ini file used is simple and I'll post the contents under the code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#NoTrayIcon

Opt("GUIOnEventMode", 1)
Opt("OnExitFunc", "Quit")

Global $MainGUI, $SecGUI, $SourceInput, $SourceRead, $DestinationInput, $DestinationRead, $Check1, $Check2, $Radio1, $Radio2, $Countpaths, $ExtInput, $ExtLabel
Global $SourceData, $CheckPathCount, $CheckSplit, $SourcePath

GUICreation()

Func OnAutoItStart()
    If @ScriptName <> "CopyFiles.exe" Then
        MsgBox(262160, "Error (Filename)", "Filename has been changed, the program will not run")
        Exit
    EndIf
    If _Singleton(@ScriptName, 1) = 0 Then
        MsgBox(262160, "Error (Already Running)", "This program is already running, only one instance is allowed!")
        Exit
    EndIf
    If FileExists(@ScriptDir & "\Settings.ini") = 0 Then
        FileInstall("E:\Settings.ini", @ScriptDir & "\Settings.ini")
    EndIf
    Call("ReduceMemory")
EndFunc   ;==>OnAutoItStart

Func ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    Return $ai_Return[0]
EndFunc   ;==>ReduceMemory

Func GUICreation()
    $AlwaysOnTop = IniRead(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", "NotFound")
    $MainGUI = GUICreate("CopyFiles", 140, 92, Default, Default, 0, $WS_EX_TOOLWINDOW)
    $Copyfiles = GUICtrlCreateButton("Copy", 5, 5, 60, 25)
    GUICtrlSetOnEvent($Copyfiles, "Copy")
    $Movefiles = GUICtrlCreateButton("Move", 5, 35, 60, 25)
    GUICtrlSetOnEvent($Movefiles, "Move")
    $ProgramOptions = GUICtrlCreateButton("Options", 70, 5, 60, 25)
    GUICtrlSetOnEvent($ProgramOptions, "Options")
    $Exit = GUICtrlCreateButton("Exit", 70, 35, 60, 25)
    GUICtrlSetOnEvent($Exit, "Quit")
    If $AlwaysOnTop = 1 Then
        WinSetOnTop($MainGUI, "", 1)
    Else
        WinSetOnTop($MainGUI, "", 0)
    EndIf
    GUISetState(@SW_SHOW)
EndFunc   ;==>GUICreation

Func Copy()
    Local $CopyError = 0
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    If $SourcePath = "" Then
        Call("SourcePathEmpty")
    Else
        FileChangeDir($SourcePath)
        $CheckSplit = StringSplit($SourcePath, ",")
        If @error = 1 Then
            $Path = FileExists($CheckSplit[1])
            If $Path = 0 Then
                Call("SourcePathInvalid1")
            Else
                Call("CopyFiles")
            EndIf
        Else
            For $CheckPathCount = 1 To $CheckSplit[0]
                $Path = FileExists($CheckSplit[$CheckPathCount])
                If $Path = 0 Then
                    Call("SourcePathInvalid2", $CheckPathCount)
                    $CopyError = $CopyError + 1
                EndIf
            Next
            If $CopyError = 0 Then
                Call("CopyFiles")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Copy

Func CopyFiles()
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $Search1 = FileFindFirstFile("*.*")
    If $Search1 = -1 Then
        Call("FolderEmpty")
    Else
        $Search2 = FileFindFirstFile($Ext)
        If $Search2 = -1 Then
            Call("NoExt")
        Else
            $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
            If $DestinationPath = "" Then
                Call("DestinationPathEmpty")
            Else
                $Overwrite = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
                $FilesOnly = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
                $SplitSource = StringSplit($SourcePath, ",")
                If @error = 1 Then
                    If $FilesOnly = 1 Then
                        FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                    Else
                        DirCopy($SplitSource[1], $DestinationPath, $Overwrite)
                        FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                    EndIf
                Else
                    If $FilesOnly = 1 Then
                        For $Countpaths = 1 To $SplitSource[0]
                            FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        Next
                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                    Else
                        For $Countpaths = 1 To $SplitSource[0]
                            DirCopy($SplitSource[$Countpaths], $DestinationPath, $Overwrite)
                            FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                            MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                        Next
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>CopyFiles



Func Move()
    Local $MoveError = 0
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    If $SourcePath = "" Then
        Call("SourcePathEmpty")
    Else
        FileChangeDir($SourcePath)
        $CheckSplit = StringSplit($SourcePath, ",")
        If @error = 1 Then
            $Path = FileExists($CheckSplit[1])
            If $Path = 0 Then
                Call("SourcePathInvalid1")
            Else
                Call("MoveFiles")
            EndIf
        Else
            For $CheckPathCount = 1 To $CheckSplit[0]
                $Path = FileExists($CheckSplit[$CheckPathCount])
                If $Path = 0 Then
                    Call("SourcePathInvalid2", $CheckPathCount)
                    $MoveError = $MoveError + 1
                EndIf
            Next
            If $MoveError = 0 Then
                Call("MoveFiles")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Move

Func MoveFiles()
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $Search1 = FileFindFirstFile("*.*")
    If $Search1 = -1 Then
        Call("FolderEmpty")
    Else
        $Search2 = FileFindFirstFile($Ext)
        If $Search2 = -1 Then
            Call("NoExt")
        Else
            $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
            If $DestinationPath = "" Then
                Call("DestinationPathEmpty")
            Else
                $Overwrite = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
                $FilesOnly = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
                $SplitSource = StringSplit($SourcePath, ",")
                If @error = 1 Then
                    If $FilesOnly = 1 Then
                        FileMove($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)
                    Else
                        DirMove($SplitSource[1], $DestinationPath, $Overwrite)
                        FileMove($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)
                    EndIf
                Else
                    If $FilesOnly = 1 Then
                        For $Countpaths = 1 To $SplitSource[0]
                            FileMove($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        Next
                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)
                    Else
                        For $Countpaths = 1 To $SplitSource[0]
                            DirMove($SplitSource[$Countpaths], $DestinationPath, $Overwrite)
                            FileMove($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                            MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)
                        Next
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>MoveFiles

Func SourcePathEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source Path)", "Source path is empty")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathEmpty

Func DestinationPathEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Destination Path)", "Destination path is empty")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>DestinationPathEmpty

Func SourcePathInvalid1()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source path)", "Source path does not exist:" & $CheckSplit[1])
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathInvalid1

Func SourcePathInvalid2($ErrorPath)
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source path)", "Source path does not exist: " & $CheckSplit[$ErrorPath])
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathInvalid2

Func FolderEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (No files/folders)", "No files/folders found in the source path")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>FolderEmpty

Func NoExt()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (No such files)", "No files with that extension found in the source path")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>NoExt

Func Options()
    GUISetState(@SW_DISABLE, $MainGUI)
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
    $OverwriteCheck = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
    $FilesOnlyCheck = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
    $AlwaysOnTop = IniRead(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", "NotFound")
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $SecGUI = GUICreate("Options", 500, 180, -175, Default, 0, $WS_EX_MDICHILD + $WS_EX_ACCEPTFILES, $MainGUI)
    GUICtrlCreateLabel("Source:", 5, 7, 45, 20)
    $SourceInput = GUICtrlCreateInput($SourcePath, 80, 5, 348, 20, $ES_AUTOHSCROLL)
    $Graphic = GUICtrlCreateGraphic(407, 62, 80, 80)
    GUICtrlSetState($Graphic, $GUI_DROPACCEPTED)
    GUICtrlSetOnEvent($GUI_EVENT_DROPPED, "GetText")
    GUICtrlSetBkColor($Graphic, 0xEAEAEA)
    GUICtrlSetColor($Graphic, 0x0000)
    GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0x0000)
    $DropLabel = GUICtrlCreateLabel("Drop Folders", 415, 93, 70, 20)
    GUICtrlSetCursor($Graphic, 3)
    GUICtrlSetState($DropLabel, $GUI_DISABLE)
    GUICtrlSetBkColor($DropLabel, 0xEAEAEA)
    GUICtrlCreateLabel("Destination:", 5, 32, 70, 20)
    $DestinationInput = GUICtrlCreateInput($DestinationPath, 80, 30, 348, 20, $ES_AUTOHSCROLL)
    $Clear = GUICtrlCreateButton("Clear", 434, 5, 55, 20)
    GUICtrlSetOnEvent($Clear, "ClearSourceInput")
    $Browse = GUICtrlCreateButton("Browse", 434, 30, 55, 20)
    GUICtrlSetOnEvent($Browse, "FolderBrowse")
    $Save = GUICtrlCreateButton("Save", 180, 120, 70, 25, $BS_DEFPUSHBUTTON)
    GUICtrlSetOnEvent($Save, "Save")
    $Cancel = GUICtrlCreateButton("Cancel", 256, 120, 70, 25)
    GUICtrlSetOnEvent($Cancel, "CloseOptions")
    $ExtLabel = GUICtrlCreateLabel("Extention", 197, 65, 70, 20)
    $ExtInput = GUICtrlCreateInput($Ext, 195, 80, 50, 20, $ES_AUTOHSCROLL)
    $Check1 = GUICtrlCreateCheckbox("Overwrite", 250, 70, 65, 20)
    If $OverwriteCheck = 1 Then
        GUICtrlSetState($Check1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Check1, $GUI_UNCHECKED)
    EndIf
    $Check2 = GUICtrlCreateCheckbox("Always on top", 250, 90, 85, 20)
    If $AlwaysOnTop = 1 Then
        GUICtrlSetState($Check2, $GUI_CHECKED)
    Else
        GUICtrlSetState($Check2, $GUI_UNCHECKED)
    EndIf
    GUICtrlCreateGroup("Copy/Move", 80, 55, 110, 60)
    $Radio1 = GUICtrlCreateRadio("Files only", 85, 70, 65, 20)
    $Radio2 = GUICtrlCreateRadio("Files and folders", 85, 90, 96, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetOnEvent($Radio1, "ExtOn")
    GUICtrlSetOnEvent($Radio2, "ExtOff")
    If $FilesOnlyCheck = 1 Then
        GUICtrlSetState($Radio1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Radio2, $GUI_CHECKED)
        GUICtrlSetState($ExtInput, $GUI_DISABLE)
        GUICtrlSetState($ExtLabel, $GUI_DISABLE)
    EndIf
    GUISetState(@SW_SHOW)
EndFunc   ;==>Options

Func GetText()
    $SourceData = GUICtrlRead($SourceInput)
    Call("SourceDropped")
EndFunc   ;==>GetText

Func SourceDropped()
    If StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then
        If $SourceData = "" Then
            GUICtrlSetData($SourceInput, @GUI_DragFile)
        Else
            GUICtrlSetData($SourceInput, "," & @GUI_DragFile, ".")
        EndIf
    EndIf
EndFunc   ;==>SourceDropped

Func ClearSourceInput()
    GUICtrlSetData($SourceInput, "")
EndFunc   ;==>ClearSourceInput

Func FolderBrowse()
    $SelectedFolder = FileSelectFolder("Choose a folder.", "", 7, "", $SecGUI)
    GUICtrlSetData($DestinationInput, $SelectedFolder, "")
EndFunc   ;==>FolderBrowse

Func CloseOptions()
    GUISetState(@SW_ENABLE, $MainGUI)
    GUIDelete(@GUI_WinHandle)
EndFunc   ;==>CloseOptions

Func ExtOn()
    GUICtrlSetState($ExtInput, $GUI_ENABLE)
    GUICtrlSetState($ExtLabel, $GUI_ENABLE)
EndFunc   ;==>ExtOn

Func ExtOff()
    GUICtrlSetState($ExtInput, $GUI_DISABLE)
    GUICtrlSetState($ExtLabel, $GUI_DISABLE)
EndFunc   ;==>ExtOff

Func Save()
    $SourceRead = GUICtrlRead($SourceInput)
    IniWrite(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", $SourceRead)
    $DestinationRead = GUICtrlRead($DestinationInput)
    IniWrite(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", $DestinationRead)
    $ExtensionRead = GUICtrlRead($ExtInput)
    If $ExtensionRead = "" Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Extension", $ExtensionRead)
    EndIf
    $CheckRead1 = GUICtrlRead($Check1)
    If $CheckRead1 = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Overwrite", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Overwrite", 1)
    EndIf
    $CheckRead2 = GUICtrlRead($Check2)
    If $CheckRead2 = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", 0)
        WinSetOnTop($MainGUI, "", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", 1)
        WinSetOnTop($MainGUI, "", 1)
    EndIf
    $RadioRead = GUICtrlRead($Radio1)
    If $RadioRead = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", 1)
    EndIf
    GUISetState(@SW_ENABLE, $MainGUI)
    GUIDelete(@GUI_WinHandle)
EndFunc   ;==>Save

Func Quit()
    GUIDelete($MainGUI)
    Exit
EndFunc   ;==>Quit

While 1
    Sleep(100)
WEnd

INI FILE settings.ini

;Set the source and destination paths.For many sources separate with a coma (,).

;The program will copy all the contents of the source(s) into the destination (the contents,not the folder itself)

;If you want to copy the folder name also, type it in the destination, so C:\Windows as the source will copy everything

;that folder contains into the destination, If you call the destination folder Windows it will be created if it doesn't exist

;and the folder will be the same

[Paths]

SourcePath=

DestinationPath=

;1 for Overwrite, 0 do not Overwrite

;1 for Files Only, 0 for folders also

;1 for always on top, 0 for off

[Options]

Overwrite=1

FilesOnly=1

AlwaysOnTop=0

Extension=*.*

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

This is where the problem is, I posted the whole program for people to see the whole thing...If you try the whole program, if you go in to options and just click in the box the script closes with error:

H:\CopyFiles.au3 (320) : ==> Unknown macro.:

If StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then

If StringInStr(FileGetAttrib(^ ERROR

The thing is how can I make the program know if I am dropping something or if I'm not dropping anything?When you drop something some trigger is supposed to be pulled, is it pulled when I just click?other then that it works...

What I want is when I drop a folder in that box (or in the input box if possible) if something is already in the input box I want it to add a coma (,) and then the path of the dragged folder else (if the input is empty) just put the path of the dragged folder...

$SecGUI = GUICreate("Options", 500, 180, -175, Default, 0, $WS_EX_MDICHILD + $WS_EX_ACCEPTFILES, $MainGUI)
    GUICtrlCreateLabel("Source:", 5, 7, 45, 20)
    $SourceInput = GUICtrlCreateInput($SourcePath, 80, 5, 348, 20, $ES_AUTOHSCROLL)
    $Graphic = GUICtrlCreateGraphic(407, 62, 80, 80)
    GUICtrlSetState($Graphic, $GUI_DROPACCEPTED)
    GUICtrlSetOnEvent($Graphic, "GetText")
    GUICtrlSetBkColor($Graphic, 0xEAEAEA)
    GUICtrlSetColor($Graphic, 0x0000)
    GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0x0000)
    $DropLabel = GUICtrlCreateLabel("Drop Folders", 415, 93, 70, 20)
    GUICtrlSetCursor($Graphic, 3)
    GUICtrlSetState($DropLabel, $GUI_DISABLE)
    GUICtrlSetBkColor($DropLabel, 0xEAEAEA)
    GUICtrlCreateLabel("Destination:", 5, 32, 70, 20)

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

(AoRaToS @ Oct 5 2008, 11:50 AM) This is where the problem is, I posted the whole program for people to see the whole thing...If you try the whole program, if you go in to options and just click in the box the script closes with error:

H:\CopyFiles.au3 (320) : ==> Unknown macro.:

If StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then

If StringInStr(FileGetAttrib(^ ERROR

The thing is how can I make the program know if I am dropping something or if I'm not dropping anything?When you drop something some trigger is supposed to be pulled, is it pulled when I just click?other then that it works...

What I want is when I drop a folder in that box (or in the input box if possible) if something is already in the input box I want it to add a coma (,) and then the path of the dragged folder else (if the input is empty) just put the path of the dragged folder...

@AoRaToS

incorrect usage of $GUI_EVENT_DROPPED, use GUISetOnEvent() not GUICtrlSetOnEvent()

then you get @GUI_DropId, @GUI_DragId and @GUI_DragFile macros.

you don't need to use Call(), just use the function name.

Call() is for running functions from string parameters, for example in an array, it's complimentary to Execute(), Assign() and Eval()

Always BitOR styles and extended styles, don't add them together

using the input control will allow for multiple folders and files

use '|' as delimiter as that is the default delimiter for dragging multiple folders or files to input (edit) control

see help file remarks for GUICtrlCreateInput()

there are examples on the forum of using registered message WM_COMMAND with input (Edit) controls

to directly control its content. search the forum for 'EN_CHANGE' and 'EN_UPDATE' messages.

see also help file example for _GUICtrlEdit_Create()

if you need multiple drag and drop folder/files capability another method is Lazycats WM_DROPFILES_FUNC() UDF

not much you can do with reducing memory usage other than good scripting cleanup practices,

interpreted scripting languages have more overhead (higher memory usage than optimized compiled programs).

Edit: fixed post borked by forum upgrade due to bug in database related to AutoIt code tags

CODE: AutoIt
#include

#include

#include

#include

#include

#include

#include

#NoTrayIcon

Opt("GUIOnEventMode", 1)

Opt("OnExitFunc", "Quit")

Global $MainGUI, $SecGUI, $SourceInput, $SourceRead, $DestinationInput

Global $DestinationRead, $Check1, $Check2, $Radio1, $Radio2, $Countpaths, $ExtInput, $ExtLabel

Global $SourceData, $CheckPathCount, $CheckSplit, $SourcePath

GUICreation()

While 1

    Sleep(1000)

WEnd

Func OnAutoItStart()

    ;If @ScriptName <> "CopyFiles.exe" Then

        ;MsgBox(262160, "Error (Filename)", "Filename has been changed, the program will not run")

        ;Exit

    ;EndIf

    If _Singleton(@ScriptName, 1) = 0 Then

        MsgBox(262160, "Error (Already Running)", "This program is already running, only one instance is allowed!")

        Exit

    EndIf

    If FileExists(@ScriptDir & "Settings.ini") = 0 Then

        FileInstall("E:Settings.ini", @ScriptDir & "Settings.ini")

    EndIf

    ;Call("ReduceMemory")

    ReduceMemory()

EndFunc   ;==>OnAutoItStart

Func ReduceMemory($i_PID = -1)

    If $i_PID <> -1 Then

        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)

        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])

        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])

    Else

        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)

    EndIf

    Return $ai_Return[0]

EndFunc   ;==>ReduceMemory

Func GUICreation()

    $AlwaysOnTop = IniRead(@ScriptDir & "Settings.ini", "Options", "AlwaysOnTop", "NotFound")

    $MainGUI = GUICreate("CopyFiles", 140, 92, Default, Default, 0, $WS_EX_TOOLWINDOW)

    $Copyfiles = GUICtrlCreateButton("Copy", 5, 5, 60, 25)

    GUICtrlSetOnEvent($Copyfiles, "Copy")

    $Movefiles = GUICtrlCreateButton("Move", 5, 35, 60, 25)

    GUICtrlSetOnEvent($Movefiles, "Move")

    $ProgramOptions = GUICtrlCreateButton("Options", 70, 5, 60, 25)

    GUICtrlSetOnEvent($ProgramOptions, "Options")

    $Exit = GUICtrlCreateButton("Exit", 70, 35, 60, 25)

    GUICtrlSetOnEvent($Exit, "Quit")

    If $AlwaysOnTop = 1 Then

        WinSetOnTop($MainGUI, "", 1)

    Else

        WinSetOnTop($MainGUI, "", 0)

    EndIf

    GUISetState(@SW_SHOW)

EndFunc   ;==>GUICreation

Func Copy()

    Local $CopyError = 0

    $SourcePath = IniRead(@ScriptDir & "Settings.ini", "Paths", "SourcePath", "NotFound")

    If $SourcePath = "" Then

        ;Call("SourcePathEmpty")

        SourcePathEmpty()

    Else

        FileChangeDir($SourcePath)

        $CheckSplit = StringSplit($SourcePath, ",")

        If @error = 1 Then

            $Path = FileExists($CheckSplit[1])

            If $Path = 0 Then

                ;Call("SourcePathInvalid1")

                SourcePathInvalid1()

            Else

                ;Call("CopyFiles")

                CopyFiles()

            EndIf

        Else

            For $CheckPathCount = 1 To $CheckSplit[0]

                $Path = FileExists($CheckSplit[$CheckPathCount])

                If $Path = 0 Then

                    SourcePathInvalid2($CheckPathCount)

                    ;Call("SourcePathInvalid2", $CheckPathCount)

                    $CopyError = $CopyError + 1

                EndIf

            Next

            If $CopyError = 0 Then

                ;Call("CopyFiles")

                CopyFiles()

            EndIf

        EndIf

    EndIf

EndFunc   ;==>Copy

Func CopyFiles()

    $Ext = IniRead(@ScriptDir & "Settings.ini", "Options", "Extension", "*.*")

    $Search1 = FileFindFirstFile("*.*")

    If $Search1 = -1 Then

        ;Call("FolderEmpty")

        FolderEmpty()

    Else

        $Search2 = FileFindFirstFile($Ext)

        If $Search2 = -1 Then

            ;Call("NoExt")

            NoExt()

        Else

            $DestinationPath = IniRead(@ScriptDir & "Settings.ini", "Paths", "DestinationPath", "NotFound")

            If $DestinationPath = "" Then

                ;Call("DestinationPathEmpty")

                DestinationPathEmpty()

            Else

                $Overwrite = IniRead(@ScriptDir & "Settings.ini", "Options", "Overwrite", "NotFound")

                $FilesOnly = IniRead(@ScriptDir & "Settings.ini", "Options", "FilesOnly", "NotFound")

                $SplitSource = StringSplit($SourcePath, ",")

                If @error = 1 Then

                    If $FilesOnly = 1 Then

                        FileCopy($SplitSource[1] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)

                    Else

                        DirCopy($SplitSource[1], $DestinationPath, $Overwrite)

                        FileCopy($SplitSource[1] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)

                    EndIf

                Else

                    If $FilesOnly = 1 Then

                        For $Countpaths = 1 To $SplitSource[0]

                            FileCopy($SplitSource[$Countpaths] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        Next

                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)

                    Else

                        For $Countpaths = 1 To $SplitSource[0]

                            DirCopy($SplitSource[$Countpaths], $DestinationPath, $Overwrite)

                            FileCopy($SplitSource[$Countpaths] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                            MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)

                        Next

                    EndIf

                EndIf

            EndIf

        EndIf

    EndIf

EndFunc   ;==>CopyFiles

Func Move()

    Local $MoveError = 0

    $SourcePath = IniRead(@ScriptDir & "Settings.ini", "Paths", "SourcePath", "NotFound")

    If $SourcePath = "" Then

        SourcePathEmpty()

        ;Call("SourcePathEmpty")

    Else

        FileChangeDir($SourcePath)

        $CheckSplit = StringSplit($SourcePath, ",")

        If @error = 1 Then

            $Path = FileExists($CheckSplit[1])

            If $Path = 0 Then

                ;Call("SourcePathInvalid1")

                SourcePathInvalid1()

            Else

                ;Call("MoveFiles")

                MoveFiles()

            EndIf

        Else

            For $CheckPathCount = 1 To $CheckSplit[0]

                $Path = FileExists($CheckSplit[$CheckPathCount])

                If $Path = 0 Then

                    SourcePathInvalid2($CheckPathCount)

                    ;Call("SourcePathInvalid2", $CheckPathCount)

                    $MoveError = $MoveError + 1

                EndIf

            Next

            If $MoveError = 0 Then

                ;Call("MoveFiles")

                MoveFiles()

            EndIf

        EndIf

    EndIf

EndFunc   ;==>Move

Func MoveFiles()

    $Ext = IniRead(@ScriptDir & "Settings.ini", "Options", "Extension", "*.*")

    $Search1 = FileFindFirstFile("*.*")

    If $Search1 = -1 Then

        ;Call("FolderEmpty")

        FolderEmpty()

    Else

        $Search2 = FileFindFirstFile($Ext)

        If $Search2 = -1 Then

            ;Call("NoExt")

            NoExt()

        Else

            $DestinationPath = IniRead(@ScriptDir & "Settings.ini", "Paths", "DestinationPath", "NotFound")

            If $DestinationPath = "" Then

                ;Call("DestinationPathEmpty")

                DestinationPathEmpty()

            Else

                $Overwrite = IniRead(@ScriptDir & "Settings.ini", "Options", "Overwrite", "NotFound")

                $FilesOnly = IniRead(@ScriptDir & "Settings.ini", "Options", "FilesOnly", "NotFound")

                $SplitSource = StringSplit($SourcePath, ",")

                If @error = 1 Then

                    If $FilesOnly = 1 Then

                        FileMove($SplitSource[1] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)

                    Else

                        DirMove($SplitSource[1], $DestinationPath, $Overwrite)

                        FileMove($SplitSource[1] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)

                    EndIf

                Else

                    If $FilesOnly = 1 Then

                        For $Countpaths = 1 To $SplitSource[0]

                            FileMove($SplitSource[$Countpaths] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                        Next

                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)

                    Else

                        For $Countpaths = 1 To $SplitSource[0]

                            DirMove($SplitSource[$Countpaths], $DestinationPath, $Overwrite)

                            FileMove($SplitSource[$Countpaths] & "" & $Ext, $DestinationPath & "" & $Ext, 8 + $Overwrite)

                            MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)

                        Next

                    EndIf

                EndIf

            EndIf

        EndIf

    EndIf

EndFunc   ;==>MoveFiles

Func SourcePathEmpty()

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (Source Path)", "Source path is empty")

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>SourcePathEmpty

Func DestinationPathEmpty()

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (Destination Path)", "Destination path is empty")

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>DestinationPathEmpty

Func SourcePathInvalid1()

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (Source path)", "Source path does not exist:" & $CheckSplit[1])

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>SourcePathInvalid1

Func SourcePathInvalid2($ErrorPath)

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (Source path)", "Source path does not exist: " & $CheckSplit[$ErrorPath])

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>SourcePathInvalid2

Func FolderEmpty()

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (No files/folders)", "No files/folders found in the source path")

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>FolderEmpty

Func NoExt()

    GUISetState(@SW_DISABLE, $MainGUI)

    MsgBox(262160, "Error (No such files)", "No files with that extension found in the source path")

    GUISetState(@SW_ENABLE, $MainGUI)

EndFunc   ;==>NoExt

Func Options()

    GUISetState(@SW_DISABLE, $MainGUI)

    $SourcePath = IniRead(@ScriptDir & "Settings.ini", "Paths", "SourcePath", "NotFound")

    $DestinationPath = IniRead(@ScriptDir & "Settings.ini", "Paths", "DestinationPath", "NotFound")

    $OverwriteCheck = IniRead(@ScriptDir & "Settings.ini", "Options", "Overwrite", "NotFound")

    $FilesOnlyCheck = IniRead(@ScriptDir & "Settings.ini", "Options", "FilesOnly", "NotFound")

    $AlwaysOnTop = IniRead(@ScriptDir & "Settings.ini", "Options", "AlwaysOnTop", "NotFound")

    $Ext = IniRead(@ScriptDir & "Settings.ini", "Options", "Extension", "*.*")

    $SecGUI = GUICreate("Options", 500, 180, -175, Default, 0, BitOR($WS_EX_MDICHILD, $WS_EX_ACCEPTFILES), $MainGUI)

    GUICtrlCreateLabel("Source:", 5, 7, 45, 20)

    $SourceInput = GUICtrlCreateInput($SourcePath, 80, 5, 348, 20, $ES_AUTOHSCROLL)

    $Graphic = GUICtrlCreateGraphic(407, 62, 80, 80)

    GUICtrlSetState($Graphic, $GUI_DROPACCEPTED)

    ;=========================================================================

    GUISetOnEvent($GUI_EVENT_DROPPED, "GetText")

    ;GUICtrlSetOnEvent($GUI_EVENT_DROPPED, "GetText")

    ;=========================================================================

    GUICtrlSetBkColor($Graphic, 0xEAEAEA)

    GUICtrlSetColor($Graphic, 0x0000)

    GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0x0000)

    GUICtrlSetCursor($Graphic, 3)

    $DropLabel = GUICtrlCreateLabel("Drop Folders", 415, 93, 70, 20)

    GUICtrlSetState($DropLabel, $GUI_DISABLE)

    GUICtrlSetBkColor($DropLabel, 0xEAEAEA)

    GUICtrlCreateLabel("Destination:", 5, 32, 70, 20)

    $DestinationInput = GUICtrlCreateInput($DestinationPath, 80, 30, 348, 20, $ES_AUTOHSCROLL)

    $Clear = GUICtrlCreateButton("Clear", 434, 5, 55, 20)

    GUICtrlSetOnEvent($Clear, "ClearSourceInput")

    $Browse = GUICtrlCreateButton("Browse", 434, 30, 55, 20)

    GUICtrlSetOnEvent($Browse, "FolderBrowse")

    $Save = GUICtrlCreateButton("Save", 180, 120, 70, 25, $BS_DEFPUSHBUTTON)

    GUICtrlSetOnEvent($Save, "Save")

    $Cancel = GUICtrlCreateButton("Cancel", 256, 120, 70, 25)

    GUICtrlSetOnEvent($Cancel, "CloseOptions")

    $ExtLabel = GUICtrlCreateLabel("Extention", 197, 65, 70, 20)

    $ExtInput = GUICtrlCreateInput($Ext, 195, 80, 50, 20, $ES_AUTOHSCROLL)

    $Check1 = GUICtrlCreateCheckbox("Overwrite", 250, 70, 65, 20)

    If $OverwriteCheck = 1 Then

        GUICtrlSetState($Check1, $GUI_CHECKED)

    Else

        GUICtrlSetState($Check1, $GUI_UNCHECKED)

    EndIf

    $Check2 = GUICtrlCreateCheckbox("Always on top", 250, 90, 85, 20)

    If $AlwaysOnTop = 1 Then

        GUICtrlSetState($Check2, $GUI_CHECKED)

    Else

        GUICtrlSetState($Check2, $GUI_UNCHECKED)

    EndIf

    GUICtrlCreateGroup("Copy/Move", 80, 55, 110, 60)

    $Radio1 = GUICtrlCreateRadio("Files only", 85, 70, 65, 20)

    $Radio2 = GUICtrlCreateRadio("Files and folders", 85, 90, 96, 20)

    GUICtrlCreateGroup("", -99, -99, 1, 1)

    GUICtrlSetOnEvent($Radio1, "ExtOn")

    GUICtrlSetOnEvent($Radio2, "ExtOff")

    If $FilesOnlyCheck = 1 Then

        GUICtrlSetState($Radio1, $GUI_CHECKED)

    Else

        GUICtrlSetState($Radio2, $GUI_CHECKED)

        GUICtrlSetState($ExtInput, $GUI_DISABLE)

        GUICtrlSetState($ExtLabel, $GUI_DISABLE)

    EndIf

    GUISetState(@SW_SHOW)

EndFunc   ;==>Options

Func GetText()

    ConsoleWrite('-@GUI_DROPID = ' & @GUI_DROPID & @crlf)

    ConsoleWrite('-@GUI_DragID = ' & @GUI_DragID & @crlf)

    ConsoleWrite('-@GUI_DragFile = ' & @GUI_DragFile & @crlf)

    $SourceData = GUICtrlRead($SourceInput)

    ;Call("SourceDropped")

    SourceDropped()

EndFunc   ;==>GetText

Func SourceDropped()

    If StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then

        If $SourceData = "" Then

            GUICtrlSetData($SourceInput, @GUI_DragFile)

        Else

            GUICtrlSetData($SourceInput, "," & @GUI_DragFile, ".")

        EndIf

    EndIf

EndFunc   ;==>SourceDropped

Func ClearSourceInput()

    GUICtrlSetData($SourceInput, "")

EndFunc   ;==>ClearSourceInput

Func FolderBrowse()

    $SelectedFolder = FileSelectFolder("Choose a folder.", "", 7, "", $SecGUI)

    GUICtrlSetData($DestinationInput, $SelectedFolder, "")

EndFunc   ;==>FolderBrowse

Func CloseOptions()

    GUISetState(@SW_ENABLE, $MainGUI)

    GUIDelete(@GUI_WinHandle)

EndFunc   ;==>CloseOptions

Func ExtOn()

    GUICtrlSetState($ExtInput, $GUI_ENABLE)

    GUICtrlSetState($ExtLabel, $GUI_ENABLE)

EndFunc   ;==>ExtOn

Func ExtOff()

    GUICtrlSetState($ExtInput, $GUI_DISABLE)

    GUICtrlSetState($ExtLabel, $GUI_DISABLE)

EndFunc   ;==>ExtOff

Func Save()

    $SourceRead = GUICtrlRead($SourceInput)

    IniWrite(@ScriptDir & "Settings.ini", "Paths", "SourcePath", $SourceRead)

    $DestinationRead = GUICtrlRead($DestinationInput)

    IniWrite(@ScriptDir & "Settings.ini", "Paths", "DestinationPath", $DestinationRead)

    $ExtensionRead = GUICtrlRead($ExtInput)

    If $ExtensionRead = "" Then

        IniWrite(@ScriptDir & "Settings.ini", "Options", "Extension", "*.*")

    Else

        IniWrite(@ScriptDir & "Settings.ini", "Options", "Extension", $ExtensionRead)

    EndIf

    $CheckRead1 = GUICtrlRead($Check1)

    If $CheckRead1 = $GUI_UNCHECKED Then

        IniWrite(@ScriptDir & "Settings.ini", "Options", "Overwrite", 0)

    Else

        IniWrite(@ScriptDir & "Settings.ini", "Options", "Overwrite", 1)

    EndIf

    $CheckRead2 = GUICtrlRead($Check2)

    If $CheckRead2 = $GUI_UNCHECKED Then

        IniWrite(@ScriptDir & "Settings.ini", "Options", "AlwaysOnTop", 0)

        WinSetOnTop($MainGUI, "", 0)

    Else

        IniWrite(@ScriptDir & "Settings.ini", "Options", "AlwaysOnTop", 1)

        WinSetOnTop($MainGUI, "", 1)

    EndIf

    $RadioRead = GUICtrlRead($Radio1)

    If $RadioRead = $GUI_UNCHECKED Then

        IniWrite(@ScriptDir & "Settings.ini", "Options", "FilesOnly", 0)

    Else

        IniWrite(@ScriptDir & "Settings.ini", "Options", "FilesOnly", 1)

    EndIf

    GUISetState(@SW_ENABLE, $MainGUI)

    GUIDelete(@GUI_WinHandle)

EndFunc   ;==>Save

Func Quit()

    GUIDelete($MainGUI)

    Exit

EndFunc   ;==>Quit

Edited by rover

I see fascists...

Link to comment
Share on other sites

WoW that was really nice of you, you helped me learn quite a few things, very helpful that you commented out my code so that I can see the difference...I would like to add a progress bar but I can't implement it correctly to copy and progress :/

Other that all that is my program any good?I know it's simple, it's my second or third program and it's mostly for my use...

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

WoW that was really nice of you, you helped me learn quite a few things, very helpful that you commented out my code so that I can see the difference...I

would like to add a progress bar but I can't implement it correctly to copy and progress :/

no problem, see the links and suggestion below for the progress dialog

Other that all that is my program any good?I know it's simple, it's my second or third program and it's mostly for my use...

Hi AoRaToS

any software you can customize to your own liking with your desired feature set and layout is good :P

I didn't spend much time on it other than fixing the drop problem, the Call usage, Bitor of styles etc.

I do like the drop zone idea.

many hits for the search terms 'CopyHere' and 'copy progress' in the forum search engine

have a look at the various methods on the forum for copy progress in these links:

you could start simply with the windows native COM method shown here:

CopyHere COM copy progress

http://www.autoitscript.com/forum/index.ph...st&p=583389

then move up to some of the more complex examples:

Copy with progress dialog...

http://www.autoitscript.com/forum/index.php?showtopic=11313

Copy with progress dialog... - multi copy dialog on german AutoIt site

http://www.autoitscript.com/forum/index.ph...st&p=586665

Yet another copy with progress

http://www.autoitscript.com/forum/index.ph...amp;#entry82020

this post has a number of links

Progress indicator for FileCopy() function., How can I show the progress of the FileCopy() function?

http://www.autoitscript.com/forum/index.ph...l=copy+progress

Cheers

I see fascists...

Link to comment
Share on other sites

Great examples, thanks allot, I'll take a look and see what I can do!By the way I want a bit of help with something... Ho can I make a simple input box drag n' drop accept only folders?

And another question, how can I check if a control in my GUI has focus?Or maybe check which control in the GUI has focus?

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

; Sample gui has buttons whose names reflect the Ctrl ID #
; Gui title tells us the control with focus
; Author: CyberSlug

#include <GuiConstants.au3>
$GUI = GuiCreate("Has focus:")

$one = GuiCtrlCreateButton("", 10, 10, 100, 50)
    GuiCtrlSetData(-1, "ButtonID " & $one)
$two = GuiCtrlCreateButton("two", 10, 110, 100, 50)
    GuiCtrlSetData(-1, "ButtonID " & $two)
$three = GuiCtrlCreateButton("three", 10, 210, 100, 50)
    GuiCtrlSetData(-1, "ButtonID " & $three)
    
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
; Constantly update title; I'm too lazy to prevent the flicker
    WinSetTitle($GUI, "", "Has focus: " & _GuiCtrlGetFocus($GUI))
WEnd


Func _GuiCtrlGetFocus($GuiRef)
    Local $hwnd = ControlGetHandle($GuiRef, "", ControlGetFocus($GuiRef))
    Local $result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
    Return $result[0]
EndFunc

:P

Link to comment
Share on other sites

Great examples, thanks allot, I'll take a look and see what I can do!By the way I want a bit of help with something... Ho can I make a simple input box drag n' drop accept only folders?

And another question, how can I check if a control in my GUI has focus?Or maybe check which control in the GUI has focus?

@AoRaToS

you can check if a control has focus with this function, a variation on Cyberslugs

Func _IsFocused($hWnd, $nCID)
    ;returns True if control has focus
    ;Author: attributed to SmOke_N by MrCreator
    ;_IsFocus(): http://www.autoitscript.com/forum/index.php?showtopic=43128
    Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc

use the UDF below to get an array of files/folders,

run fileattrib to check if array element is folder

read previous contents of input with GuiCtrlRead

then concatenate previous contents with array folders into one string with a "|" delimiter and GuiSetdata to input control

or switch to a listview so user can edit final list of folders to copy or move (use GuiListview UDFs in help file)

input/edit control can also be subclassed to manipulate dropped files/folder so they concatenate

instead of the default drop action overwriting previous content with single or multi dropped folders.

but input/edit control is problematic with dropped files/folders:

sometimes a dropped folder(s) is inserted into previous input control content at the caret position

without a delimiter! ("|") between folders, or partially overwrites at caret position in edit control.

Note: test this with the example for GUICtrlCreateInput() in help file

drop multiple folders on input (edit) control, then drop one or two folders

normally previous content is overwritten.

intermittently you get something like this actual test result:

Drop 5 folders:

C:\Dev-Cpp\libexec|C:\Dev-Cpp\Help|C:\Dev-Cpp\Icons|C:\Dev-Cpp\include|C:\Dev-Cpp\Lang

Drop 2 folders: C:\Dev-Cpp\libexec|C:\Dev-Cpp\lib

Result:

C:\Dev-Cpp\libexec|C:\Dev-Cpp\Help|C:\Dev-Cpp\Icons|C:\Dev-Cpp\include|C:\Dev-Cpp\Lang|C:\C:\Dev-Cpp\libDev-Cpp\lib

Author: Lazycat

Drop multiple files on any control, With GUIRegisterMsg

http://www.autoitscript.com/forum/index.ph...l=DragQueryFile

Author: Siao

Can't get files dropped onto gui to be accepted.

http://www.autoitscript.com/forum/index.ph...mp;#entry412438

see post in this thread, example of populating a listview with dragged files

[sOLVED] InfoTip is behind the main window

http://www.autoitscript.com/forum/index.ph...st&p=581755

I see fascists...

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