Sundance Posted July 13, 2005 Posted July 13, 2005 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
Valuater Posted July 13, 2005 Posted July 13, 2005 (edited) 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 July 13, 2005 by Valuater
Sundance Posted July 13, 2005 Author Posted July 13, 2005 (edited) 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 July 13, 2005 by Sundance
Valuater Posted July 13, 2005 Posted July 13, 2005 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)
Sundance Posted July 14, 2005 Author Posted July 14, 2005 (edited) 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 so thx for the replay Edited July 14, 2005 by Sundance
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now