Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

  FireFox said:

@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
  • 3 weeks later...
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...