RegiOween

Two questions about Drag & Drop

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

"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

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
Share on other sites
5 minutes ago, careca said:

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

Why?

Maybe the OP means to drop file(s) onto the app/script itself.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
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!

Share this post


Link to post
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