Sign in to follow this  
Followers 0
leuce

How to make script detect if drag/drop was used

3 posts in this topic

G'day everyone

I have created EXE scripts in the past that worked with drag-and-drop, but I would like to create a script that can detect whether it was double-clicked or whether something was dragged and dropped onto it. How can I do that?

So, what I need to do is to let the script determine if $CmdLine[1] exists or not. If it exists, the script should use the drag-and-dropped file as the first parameter, but if not, then the script should ask the user (via e.g. a FileOpenDialog) what the first parameter is.

However, my problem is that I can't check if $CmdLine[0] is zero unless $CmdLine is already an array. I can't check if $CmdLine is an array unless $CmdLine already exists. However, if I declare $CmdLine, then it destroys the first parameter (if there is one). So how do I get around this problem?

I would really like to make ONE script (not two) that the user can either double-click or drag-and-drop to.

Thanks

Samuel

Share this post


Link to post
Share on other sites



I have created EXE scripts in the past that worked with drag-and-drop, but I would like to create a script that can detect whether it was double-clicked or whether something was dragged and dropped onto it. How can I do that?

Wait... this seems to work:

If $CmdLine[0] = 1 Then
MsgBox (0, "", "is one", 0)
EndIf

If $CmdLine[0] = 0 Then
MsgBox (0, "", "is none", 0)
EndIf

This would mean that $CmdLine is automatically always an array in any script... right?

Samuel

Share this post


Link to post
Share on other sites

leuce,

This would mean that $CmdLine is automatically always an array in any script... right?

I believe that is correct - $CmdLine is created automatically by AutoIt as the script is launched and sized according to the actual command line passed to it. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  
Followers 0