Jump to content
Sign in to follow this  
James

Drag a file to an edit box then open it?

Recommended Posts

BALA

$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)

MsgBox (4096, "drag drop file", GUICtrlRead($file))

Just have it open $file


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites
James

Ahh thats it. Thanks Ba-La

Secure

Edit: How can I make that work with an edit box? When I drag a file, nothing happens. If you goto my topic you can look through all the source code and find out why.

Edited by Secure_ICT

Share this post


Link to post
Share on other sites
GaryFrost

AFAIK it doesn't work with Edit control might try something like

#include <GuiConstants.au3>

; GUI
;Note GUI Created with the Extended Windows Style ACCEPTFILES
GUICreate("Drag/Drop Demo", 220, 220, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

; INPUT
;string for default status of InputBox
Global $txtInput = "Input Box Accepts Files"
;Create handle for Input Box.
Global $hInput = GUICtrlCreateInput($txtInput, 10, 10, 200, 200, BitOR($ES_MULTILINE, $ES_LEFT, $ES_AUTOHSCROLL));Specify that the control can respond to ACCEPTFILES messages
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
Global $hEdit = GUICtrlCreateEdit("",10,10,200,200)
GUICtrlSetState($hEdit, $GUI_HIDE)
GUISetState()
;Initialize Message Status
Local $msg = ""
; GUI MESSAGE LOOP
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
;UDF to Monitor Controls that Accept Drag / Drop
;This is necessary becuase the drop operation does NOT send a message to the control,
;It simply dumps the CRLF separated list of files in the control, appending them to what went before.
    _MonitorFiles()
    
WEnd
Exit $msg

;===============================================================================
;
; Function Name:      _MonitorFiles
; Description:        Demonstrate Looping to Monitor the change of a drag/drop file operation
; Parameter(s):       None
; Requirement(s):     Autoit3.1.0
; Return Value(s):    None
; Author(s):          FlyingBoz
; Date:               20 Feb 2005

Func _MonitorFiles()
;FlyingBoz - monitor contents of $hinput control,
;display and reset when triggered.
    Local $text = GUICtrlRead($hInput)
    If $text <> $txtInput Then;Something has changed
;strip the default text
        $text = StringReplace($text, $txtInput, "")
;display what's left.
        $text = StringReplace($text, "|", @CRLF)
;~         MsgBox(0, "Change In Input Box!", $text, 0)
;NOTE: Obviously, more sophisticated handling
;should occur here - You will see when Files are
;dropped, this @CRLF separated list
;can be parsed, tested with If FileExists(), etc.
        $txtInput = GUICtrlRead($hInput)
          If FileExists($txtInput) Then
            $s_text = FileRead($txtInput)
            GUICtrlSetData($hEdit, $s_text)
            GUICtrlSetState($hEdit, $GUI_SHOW)
            GUICtrlSetState($hInput, $GUI_HIDE)
          EndIf
    EndIf
EndFunc ;==>_MonitorFiles
;===============================================================================

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
BALA

Well, like gafrost said, I don't think it's possible with an Edit control

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites
BALA

Oh, so it does, must've missed that part :)

EDIT: Actually, I think what it does is have an invisible input behind the edit box, and it updates the edit box with GUISetData with the text inside the file specified by the input. (Sorta what I suggested, except using an input instead of a dummy.)

EDIT EDIT: Sorry, it's the other way around XP

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites
BALA

What's actually happening is that there's a hidden input that takes the path of the file. The program then reads the text inside the file and then sends it to the edit control.

Wow, I sure wish I could program some more of your BetaPad :)

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites
GaryFrost

Works with 3.2.2.0 and 3.2.1.14

#include <GuiConstants.au3>
#include <GuiEdit.au3>

; GUI
;Note GUI Created with the Extended Windows Style ACCEPTFILES
GUICreate("Drag/Drop Demo", 220, 220, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

; INPUT
;string for default status of InputBox
Global $txtInput = "Input Box Accepts Files"
;Create handle for Input Box.
Global $hEdit = GUICtrlCreateEdit($txtInput, 10, 10, 200, 200)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
_GUICtrlEditSetSel($hEdit, 0, -1)
GUISetState()
;Initialize Message Status
Local $msg = ""
; GUI MESSAGE LOOP
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    ;UDF to Monitor Controls that Accept Drag / Drop
    ;This is necessary becuase the drop operation does NOT send a message to the control,
    ;It simply dumps the CRLF separated list of files in the control, appending them to what went before.
    _MonitorFiles()

WEnd
Exit

;===============================================================================
;
; Function Name:      _MonitorFiles
; Description:        Demonstrate Looping to Monitor the change of a drag/drop file operation
; Parameter(s):       None
; Requirement(s):     Autoit3.1.0
; Return Value(s):    None
; Author(s):          FlyingBoz
; Date:               20 Feb 2005

Func _MonitorFiles()
    ;FlyingBoz - monitor contents of $hinput control,
    ;display and reset when triggered.
    Local $text = GUICtrlRead($hEdit)
    If $text <> $txtInput Then;Something has changed
        ;strip the default text
        $text = StringReplace($text, $txtInput, "")
        ;display what's left.
        $text = StringReplace($text, @CRLF, "")
        ;NOTE: Obviously, more sophisticated handling
        ;should occur here - You will see when Files are
        ;dropped, this @CRLF separated list
        ;can be parsed, tested with If FileExists(), etc.
        If FileExists($text) Then
            $s_text = FileRead($text)
            GUICtrlSetData($hEdit, "")
            GUICtrlSetData($hEdit, $s_text)
            $txtInput = GUICtrlRead($hEdit)
        EndIf
    EndIf
EndFunc   ;==>_MonitorFiles
;===============================================================================

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

Yes that does work :)

Right, I have it all setup to work with BetaPad, but it still wont work. It wont let me drag files.

Have to make sure to $WS_EX_ACCEPTFILES when creating the gui

GUICreate("Drag/Drop Demo", 220, 220, -1, -1, -1, $WS_EX_ACCEPTFILES)oÝ÷ Ù©ÝÓ~PCÓÄJíç×(Úè«­¢+Ù±½°ÀÌØí¡¥ÐôU%
Ñɱ
ÉѥРÀÌØíÑáÑ%¹ÁÕаÄÀ°ÄÀ°ÈÀÀ°ÈÀÀ¤)U%
ÑɱMÑMÑÑ ´Ä°ÀÌØíU%}

AQ%1L¤(

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

Yes, when I do:

$BetaPad = GUICreate("BetaPad | Untitled", 626, 466, @DesktopHeight / 3, @DesktopWidth / 5, $WS_EX_ACCEPTFILES)
oÝ÷ Ù8^]»­¶Ý˥櫳ú®¢×ºÚ"µÍÌÍÐ]TYHÕRPÜX]J   ][ÝÐ]TY[]Y    ][ÝË


ÚÝÜZYÚÈËÚÝÜÚYÈ
K]Ô    ÌÍÕÔ×ÑVÐPÐÑTSTË   ÌÍÕÔ×ÑVÐTÒSÕÊJB

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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.