Jump to content

Two questions about Drag & Drop


 Share

Recommended Posts

Hello, folks!

Two questions about Drag & Drop:

1) Searching the forum, I found a way to make non-compiled scripts to accept drag & drop files as parameters, creating a registry key:

RegWrite("HKEY_CLASSES_ROOT\AutoIt3Script\ShellEx\DropHandler", "", "REG_SZ", "{86C86720-42A0-1069-A2E8-08002B30309D}")

This seems to be a hidden trick, since I didn't find any related references in documentation. Is there some another way to enable this feature manually, without messing with the registry? (I mean, interactively, not programmatically).

2) Suppose I have a file in the path "X:\Folder Name\File Name.ext" and the following script:

MsgBox(0, "", $CmdLine[0] & @LF & $CmdLine[1])

If I drag & drop the file to the non-compiled script, I have the following undesired results:

$CmdLine[0] returns:  3
$CmdLine[1] returns:  X:\Folder

However, if I drag & drop the file to the compiled script, I have the following desired results:

$CmdLine[0] returns:  1
$CmdLine[1] returns:  X:\Folder Name\File Name.ext

I have tried using many combinations of single and double quotes around the path, but neither worked, so I'm asking the experts... :)
Thanks in advance!

Edited by RegiOween
Link to comment
Share on other sites

Im sorry, i didn't understand the question, drag and drop as parameter? Read it again, i get it now.

Here's an example of drag and drop:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Example()

Func Example()
    Local $listview, $button, $item1, $item2, $item3, $item4, $msg
    GUICreate("Drop in Listview", 420, 200, 100, 100, -1, $WS_EX_ACCEPTFILES)
    $listview = GUICtrlCreateListView("Files", 10, 10, 400, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSendMsg($listView, $LVM_SETCOLUMNWIDTH, 0, 380)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_DROPPED
                GUICtrlCreateListViewItem(@GUI_DRAGFILE, $listview)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

EDIT: tested that, and it worked the same way compiled and uncompiled:

$CmdLine[0] returns:  1
$CmdLine[1] returns:  X:\Folder Name\File Name.ext

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

careca, your script works, but for what I'm trying to do, it has some drawbacks:

1) It uses a GUI, that I don't want to open anywhere on the screen, because my purpose is use it as a SendTo Windows shortcut.
2) It works on 2 steps, first open the script, then drop the files in the GUI
3) I tested with more than one file, but just the first filename appears on the GUI

Anyway, thank you for the help!

Link to comment
Share on other sites

"i want to be able to "import" multiple files through cmd line"

that's workable.

So what do you need? you brought drag and drop into this mix, and it seems it has nothing to do with it, im confused sorry.

To be a drag and drop there has to be a gui. So..

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

28 minutes ago, careca said:

"i want to be able to "import" multiple files through cmd line"

that's workable.

So what do you need? you brought drag and drop into this mix, and it seems it has nothing to do with it, im confused sorry.

To be a drag and drop there has to be a gui. So..

careca, the whole point is that the one line script I wrote as an example in the first post is working flawlessly compiled (drag & drop one or more files directly onto the script), but returns completely different values non-compiled, and I don't have a clue about the reason.

Edited by RegiOween
Link to comment
Share on other sites

My tests with your example work the same way compiled or not.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

4 hours ago, careca said:

My tests with your example work the same way compiled or not.

Well, now I'm even more lost. Running a Windows 7 SP1 64bit here, with AutoIt 3.3.14.2 (latest stable version) running in 32bit mode. Maybe there's something wrong with my system. I'll try to find out what's going on, and keep you updated. Thanks for the help!

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