Jump to content

Using Drag and Drop


Ray
 Share

Recommended Posts

Yesterday, after finishing a short routine that would enable a client to automate the reformating of a data file, I was asked to make it so the client could use the routine by utilizing Windows Drag-and-Drop capabilities.

My search of this forum produced nothing that would help me with a solution (I'm sure I just didn't search for the right infomation.) So, I went to the help files and found something that lead me to the answer.

Here is an example of the solution, just incase others might have the need for it.

To use this example, just compile it and place the exe or a short cut to the exe on the desktop. Then drag a file onto the exe (or shortcut) Icon.

If $CmdLine[0] <> "" Then 
    $SourceFile = $CmdLine[1]
Else
    Exit
EndIf

MsgBox(0, "The file used was:", $SourceFile)
Exit
Edited by Ray
Link to comment
Share on other sites

Or if a user select several files the CmdLine looks like this:

"file1" "file2" "file3"

so I use:

$line = StringSplight($CmdLineRaw," ")
If $line[0] Then
   For $I = 1 to $line[0]
       $SelectFile = StringReplace( $line[$I], '"',""); Remove Quotes
       MsgBox( 0, @ScriptName, $SelectFile)
   Next
EndIf
Edited by leecole

Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits

Link to comment
Share on other sites

i would think Ray has the right idea, because once a file is dropped.. the exe would execute immediatly...No??

8)

But the user can hold down CTRL and select nultiple files and drag the group to the shortcut and drop the entire group.

Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits

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