edthedestroyer Posted February 15, 2012 Share Posted February 15, 2012 (edited) I'm trying to create an interface where users drag a file (a picture) into the window, and the file is copied to a new location for further use in the main program. Func drag() ;window for receiving drag and drop pictures. $winhand2 = GUICreate("Drag Photo Here",200,200,0,-1,-1, $WS_EX_ACCEPTFILES) $file=0 $edit1=GUICtrlCreateEdit("", 10,30,180,160,$ES_AUTOVSCROLL) GUICtrlSetState(-1,$GUI_DROPACCEPTED) GUISetState() while (1) $msg=Guigetmsg() switch $msg case $GUI_EVENT_CLOSE ExitLoop case $GUI_EVENT_DROPPED MsgBOx(64,"",@GUI_DRAGFILE) ;shows me that the correct filepath was imported $ee=FileCopy(@GUI_DRAGFILE,@MyDocumentsDir & "\tempscr.bmp",9) MsgBOx(64,"",$ee) ;tells me if the filecopy fails, it always does ExitLoop EndSwitch Wend GUIDelete() EndFunc The problem is, the script will not copy the file. It has the correct filepath but the copy always fails. It's as if the file is being used and can't be copied when you drag and drop the file. Solution: @GUI_DRAGFILE contains a @CRFL which needed to be removed before FileCopy can find the source. FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""),@MyDocumentsDir & "\tempscr.bmp",9) Thanks Aipion! Edited February 16, 2012 by edthedestroyer Link to comment Share on other sites More sharing options...
igorisbar Posted February 15, 2012 Share Posted February 15, 2012 Path to Truth starts here: http://ap.freewey.com You can publish your links at the page "Your site". Link to comment Share on other sites More sharing options...
edthedestroyer Posted February 15, 2012 Author Share Posted February 15, 2012 Thank you spambot. If I put the filepath in the filecopy it works just fine. But if the pathfile is pulled for @GUI_DRAGEFILE which appears to be the exact same string, the filecopy fails. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2012 Share Posted February 16, 2012 When you Drag & Drop a file, the @GUI_DRAGFILE has the file path with a @CRLF. so you have to just remove it then it will work. This should Work: Func drag() ;window for receiving drag and drop pictures. $winhand2 = GUICreate("Drag Photo Here",200,200,0,-1,-1, $WS_EX_ACCEPTFILES) $file=0 $edit1=GUICtrlCreateEdit("", 10,30,180,160,$ES_AUTOVSCROLL) GUICtrlSetState(-1,$GUI_DROPACCEPTED) GUISetState() while (1) $msg=Guigetmsg() switch $msg case $GUI_EVENT_CLOSE ExitLoop case $GUI_EVENT_DROPPED MsgBOx(64,"",@GUI_DRAGFILE) ;shows me that the correct filepath was imported $ee=FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""),@MyDocumentsDir & "tempscr.bmp",9) MsgBOx(64,"",$ee) ;tells me if the filecopy fails, it always does ExitLoop EndSwitch Wend GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
edthedestroyer Posted February 16, 2012 Author Share Posted February 16, 2012 o_0 Do you have a script for getting the past hour of my life back? Thanks very much. Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2012 Share Posted February 16, 2012 o_0Do you have a script for getting the past hour of my life back?Thanks very much.No But i hope there is one in the future. LOL Link to comment Share on other sites More sharing options...
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