Jump to content

checking drag&drop into a textfield


Recommended Posts

Hiho.

I'am new to AutoIt and tried to make a simple editor.

I have now a little prob and haven't found so far a satisfying solution.

My editor has a one-line text inputfield wich accepts drag&drop.

When there is the name of the file droped into the textfield i want this to

be recognized and then load the content of the file into another textfield.

GuiGetMsg seems not to be able for checking this.

Is there a solution for this??

thx in advance :)

Link to comment
Share on other sites

straight from help.... try searching it.... First

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)
GUICtrlCreateInput ("", 10,  35, 300, 20)  ; will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               exitloop
       EndSelect
Wend

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

$answer = guictrlread($file)

this will do the trick

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

thx !!!

i searched the help file for 3 hours.

i've found the code snipped but it doesnt seem doing the trick. when do i know, the drop is made ?

say i wanna pop up a messagebox when a file is dropped into the textfield...

cant see it work. there is no gui-event for this

Edited by Sundance
Link to comment
Share on other sites

I DO NOT suggest this.... because it does not give the user time to "type" in a file location

but this is what you wanted

#include <GUIConstants.au3>
Dim $answer = ""
GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10,  25, 300, 20)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)

GUISetState () 

$msg = 0
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
    $answer = GUICtrlRead($file); reads the drag & drop box every second
    If $answer <> "" Then
        Sleep(200); give time for mouse to actually let-go of the dropped file
        If FileExists($answer) Then;checks that the file exists
            MsgBox (4096, "drag drop file", $answer)
        ; call "read file" function
            Sleep(1000); remove this sleep when you have your read function working
        Else
            MsgBox (4096, "drag drop file", "file was not found")
        EndIf
    EndIf   
    
    Sleep(1000)  
Wend

hope it helps

8)

NEWHeader1.png

Link to comment
Share on other sites

i thought you would say this :-). As you said, it could heavily uses the system capacity quite strongly.

but it seems to be the only working way. i will try it and see how it pulls my computer down :evil:

so thx for the replay :)

Edited by Sundance
Link to comment
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
 Share

  • Recently Browsing   0 members

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