Jump to content
Sign in to follow this  
Marc Lacrosse

retrieving the path of a file that is dragged on my script's icon?

Recommended Posts

Marc Lacrosse

I would like the user of a compiled script to be allowed to drag a file in windows explorer and drop it on the icon or name of my compiled script .

this would launch the script with the dragged file path as a parameter.

There are languages where such a case is dealt with the same syntax as retrieving a pure command line parameter (as if the script had been launched with the following command : "Myscript.exe myfile.txt").

This does not seem to be the case with auto-it :

a simple script like the following does not work if I drag a file on the resulting exe :

if $CmdLine[0] < 1 then
    MsgBox(0,"Test CL & Drag'n Drop", "No file on CL or DnD")
Else
    MsgBox(0,"Selected File : ",$CmdLine[1]
EndIf

Would you please tell me how I may retrieve the path of a file that has been dropped on my compiled script's name ?

Thanks in advance

Marc

PS sorry if this has been answered yet : I was not able to find the answer in the docs or in the forum.

Share this post


Link to post
Share on other sites
smashly

Works for me as long as you add the missing end bracket to the msgbox.

MsgBox(0,"Selected File : ",$CmdLine[1])

Share this post


Link to post
Share on other sites
martin

I would like the user of a compiled script to be allowed to drag a file in windows explorer and drop it on the icon or name of my compiled script .

this would launch the script with the dragged file path as a parameter.

There are languages where such a case is dealt with the same syntax as retrieving a pure command line parameter (as if the script had been launched with the following command : "Myscript.exe myfile.txt").

This does not seem to be the case with auto-it :

a simple script like the following does not work if I drag a file on the resulting exe :

if $CmdLine[0] < 1 then
    MsgBox(0,"Test CL & Drag'n Drop", "No file on CL or DnD")
Else
    MsgBox(0,"Selected File : ",$CmdLine[1]
EndIf

Would you please tell me how I may retrieve the path of a file that has been dropped on my compiled script's name ?

Thanks in advance

Marc

PS sorry if this has been answered yet : I was not able to find the answer in the docs or in the forum.

Apart from a missing closing bracket, there is nothing wrong with your code.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Marc Lacrosse

Works for me as long as you add the missing end bracket to the msgbox.

MsgBox(0,"Selected File : ",$CmdLine[1])

Oooops ....

Sorry

... and thanks to all

Marc

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.