Jump to content
Sign in to follow this  
QA Stooge

Populating FileOpenDialog with Drag & Drop

Recommended Posts

QA Stooge

As it stands, the canned input prompts like FileOpenDialog, FileSaveDialog, FileSelectFolder and InputBox, do not accept drag & drop from windows explorer. For example, if I have a "My Documents" window open, I cant drag a file from that window and drop it into the above prompts to populate it with the path&filename.

Is there a setting somewhere to change this?

Edited by QA Stooge

Share this post


Link to post
Share on other sites
FireFox

@QA Stooge

Why using drag for fileopendialog ? :)

For drop files you can use little gui where you drop your file and then you ask user where to save the dropped file with fileselectfolder :o

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
QA Stooge

@QA Stooge

Why using drag for fileopendialog ? :)

For drop files you can use little gui where you drop your file and then you ask user where to save the dropped file with fileselectfolder :lmao:

Cheers, FireFox.

I was thinking more along the lines of a simple, generic, application.

For example, I have one called XMLtidy, which I use to pretty up (for human readability) some ugly XML output, generated by a 3rd party XSLT engine. It would save time for me and my QA team to not have to copy & paste the folder path, when we can just drag & drop the file icon itself from an explorer window.

Edited by QA Stooge

Share this post


Link to post
Share on other sites
P388l3s

here's some code I've been working on for a similar app here at work, I've tidied it up a bit and left a great big pointer to where to put your code.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt ( 'GUIOnEventMode', 1 )
Opt ( 'TrayOnEventMode',1 )
Opt ( 'TrayMenuMode', 3 )
TraySetClick ( 8 )

$Gui = GUICreate ( 'Drag Drop', 75, 30, -1, -1, -1, $WS_EX_ACCEPTFILES + $WS_EX_TOOLWINDOW ); + $WS_EX_APPWINDOW
$GRP = GUICtrlCreateGroup ( 'Drop File', 2, 2, 71, 26 ) 
GUICtrlSetState ( $GRP, $GUI_DROPACCEPTED )

$TrayExit = TrayCreateItem ( 'Exit' )
TrayItemSetOnEvent ( $TrayExit, 'ExitEvent' )

GUISetState ( @SW_SHOW, $Gui )

Func _BringToFront ( )
    If Not WinActive ( $Gui ) Then
        WinActivate ( $Gui )
    EndIf
EndFunc

Func _GUI ( )
    TraySetOnEvent ( $TRAY_EVENT_PRIMARYDOWN, '_BringToFront' )
    GUISetOnEvent ( $GUI_EVENT_CLOSE, "SpecialEvents" )
    GUISetOnEvent ( $GUI_EVENT_MINIMIZE, "SpecialEvents" )
    GUISetOnEvent ( $GUI_EVENT_RESTORE, "SpecialEvents" )
    GUISetOnEvent ( $GUI_EVENT_DROPPED, '_dropped' )
    While 1
        Sleep ( 10 )
    WEnd
EndFunc

Func SpecialEvents ( )
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            ExitEvent ( )
    EndSelect
EndFunc  ;==>SpecialEvents

Func ExitEvent ( )
    Exit
EndFunc

Func _dropped ( )
;@GUI_DRAGID, @GUI_DRAGFILE and @GUI_DROPID 
;MsgBox ( 4096 + 64, 'Output', @GUI_DRAGFILE )
    If FileExists ( @GUI_DRAGFILE ) Then
    #cs
    
    YOUR CODE GOES HERE!!!
    
    #ce
    Else
    ;Redundant test.
    EndIf
EndFunc

_GUI ( )

Just remember @GUI_DRAGFILE is your actual filename to work with. If you left click the tray icon it brings the window to the front, a right click gives you a menu (exit only) and you should be set from there.

Hope this helps.

Pebbles.

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  

×