Sign in to follow this  
Followers 0
Inverted

How to enable drag drop for Autoit scripts ?

10 posts in this topic

#1 ·  Posted (edited)

Hello, first poster here !

Seems windows only allows drag and drops for some extensions/filetypes. Well, I can't drag&drop on AutoIt scripts :)

(I want to make a script that will rename a bunch of files, and I thought it'd be easy to get the filenames from that $CmdLine array)

EDIT: XP fully updated, latest autoit. Can you guys drag&drop to your scripts ?

Edited by Inverted

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hey,

Welcome to the AutoIt forums :lmao:

I can't speak for all of us but i can drag and drop to my scripts yes :)

There is some info about it in the help file under GUICtrlCreateEdit for example but i noticed it needs updating.

i made working example for you to play with :think:

#include <GuiConstantsEx.au3>
#include <EditConstants.au3> ; $WS_EX_ACCEPTFILES should be in here according to the help file

Global Const $WS_EX_ACCEPTFILES = 0x00000010
Global $sEditText = ""

GUICreate("Drag And Drop Example", 200, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)
$hEdit = GUICtrlCreateEdit($sEditText, 8, 8, 184, 184)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; $GUI_ACCEPTFILES / $GUI_DROPACCEPTED
GUISetState()

While GUIGetMsg() <> -3 
    If GUICtrlRead($hEdit) <> $sEditText Then ; content changed so file has been dropped
        ConsoleWrite("FILE(S) DROPPED: " & GUICtrlRead($hEdit))
        GUICtrlSetData($hEdit, "")
    EndIf
    Sleep(25)
WEnd
Edited by Robjong

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oops, I didn't mean that kind of drag'n'drop, I mean drag'n'drop as in with batch files, exe files etc. To pass command-line parameters !

For the moment I made a batch file to "start" my script with the parameters. So I drag'n'drop the files to the batch file instead of the script file :

CODE
cd /d %0\..

start MassRenamer.au3 %*

rem pause

My script (MassRenamer) is doing batch renaming.

Can you guys d'n'd to .au3 files ?

Edited by Inverted

Share this post


Link to post
Share on other sites

Read my previous post please.

Share this post


Link to post
Share on other sites

Read my previous post please.

yes ... i've read your post before my reply...

try my example in a blank autoit script and drag some files on it (if it dosen't work in au3 form try compiling it)


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

Actually, it's quite simple in WSH, if the script (AutoIt) could be bound to the WScript object so you can get the Arguments collection and process mass drop'n'drag files but I have no clue how to get reference to the WScript '_'

Share this post


Link to post
Share on other sites

Why would you even want to do that when AU3 is cable of doing that. Did you even read or attempt to run the code TheMadman posted above?

Actually, it's quite simple in WSH, if the script (AutoIt) could be bound to the WScript object so you can get the Arguments collection and process mass drop'n'drag files but I have no clue how to get reference to the WScript '_'

Share this post


Link to post
Share on other sites

Actually, it's quite simple in WSH, if the script (AutoIt) could be bound to the WScript object so you can get the Arguments collection and process mass drop'n'drag files but I have no clue how to get reference to the WScript '_'

don't mean to be rude but why use wscript when you can use plain autoit for it?


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

yes ... i've read your post before my reply...

try my example in a blank autoit script and drag some files on it (if it dosen't work in au3 form try compiling it)

Dragging and dropping on .au3 doesn't do anything, it doesn't start the script.

But you reminded me I can also compile the scripts, now it works as intended. Ha, how embarassing !!

Still, it would be interesting if dragging and dropping was possible on non-compiled scripts. As in batch files.

Thanks for the help everyone.

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