Xandy Posted March 8, 2011 Share Posted March 8, 2011 (edited) With drag and drop files, I really need a way to parse the files dropped before they land on an input field. Or I need away to clear the input field before the file drop takes place For example if I only drop one file, I can set the input field to the @gui_dragfile however if I drop 2 or more files, I have only learned that I can parse the input field for the separator char "|". This works fine if the input I drop the files onto is empty, But when I drop files onto a input with a value not equal to "" the file path is inserted into the input field whereever I released the mouse button makeing it very hard to distingwish between the new path I want inserted into the input field and the old input data I want removed I could add a check for $GUI_EVENT_PRIMARYUP then decide if the mouse is over a input field but I don't want to clear the field everytime the mouse is released over an input field, I only want to clear the field if I'm dropping files onto it. Is there a way to analize only the files dropped without reading the input field value? Or a way to clear the input field before the drop takes place? I have searched for days over months to find a solution to this issue, and I must not know the right way to search for this answer. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $inputfieldmax= 10 $hgui= 0 if $hgui== 0 then $hgui = guicreate("Drag, drop file", 600, $inputfieldmax*30, 0, 0, -1, $WS_EX_ACCEPTFILES); endif ;create input fields dim $inputfield[$inputfieldmax] for $i= 0 to $inputfieldmax-1 GUICtrlCreateLabel($i, 5, 10+29*$i) $inputfield[$i] = GUICtrlCreateInput("", 25, 10+29*$i, 340, 21) GUICtrlSetState($inputfield[$i], $GUI_DROPACCEPTED) next GUISetState(@sw_show) dim $function[$inputfieldmax]; $done= 0 while $done== 0 $msg= GUIGetMsg() if $msg== $GUI_EVENT_DROPPED then for $i=0 to $inputfieldmax-1 $tempstring= GUICtrlRead($inputfield[$i]) $filedrop= StringSplit($tempstring, "|") for $ii= 1 to $filedrop[0] if($filedrop[0]== 1 and $inputfield[$i+$ii-1]== @GUI_DropId) then $function[$ii-1]= @GUI_DragFile Else $function[$ii-1]= $filedrop[$ii] endif GUICtrlSetData($inputfield[$i+$ii-1], $function[$ii-1]) next next endif if $msg== $GUI_EVENT_CLOSE then $done= 1 WEnd Guinness thank you for directing me to the solution to my problem. I was reluctant to use GUIRegisterMsg() when I saw a similar autoit topic because the function reminded me of a callback function I had registered previously to capture scroll mouse wheel events: $hFunc = DllCallbackRegister('_MouseProc', 'lresult', 'int;int;int') the callback function caused right-click panning to become crazy fast, as in a slight movement of the mouse resulted in the cursor leaving the window. So I decided that registering callbacks effected system speed behavior and removed the ability to capture scroll mouse wheel events. Because I don't really understand dll stuff or how everything works here in autoit, I was too reluctant to try the GUIRegisterMsg() example. Because you told me WM_DROPFILES was what I needed, I tried it. It works perfectly so far, and does not cause the pann glitch. Now comparing the DllCallbackRegister() and GUIRegisterMsg(), I will only suspect registering callbacks to heavy effect system performance. Thanks again, here is the code that allows me to overwrite the input field with drag drop files: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $inputfieldmax= 10 $hgui= 0 Global Const $WM_DROPFILES = 0x233 Global $gaDropFiles[1] GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC") if $hgui== 0 then $hgui = guicreate("Drag, drop file", 600, $inputfieldmax*30, 0, 0, -1, $WS_EX_ACCEPTFILES); endif ;create input fields dim $inputfield[$inputfieldmax] for $i= 0 to $inputfieldmax-1 GUICtrlCreateLabel($i, 5, 10+29*$i) $inputfield[$i] = GUICtrlCreateInput("", 25, 10+29*$i, 340, 21) GUICtrlSetState($inputfield[$i], $GUI_DROPACCEPTED) next GUISetState(@sw_show) dim $function[$inputfieldmax]; $done= 0 while $done== 0 $msg= GUIGetMsg() if $msg== $GUI_EVENT_DROPPED then for $i= 0 to $inputfieldmax-1 if $inputfield[$i]== @GUI_DropId Then $temp= $i ExitLoop endif next For $i= 0 To UBound($gaDropFiles) - 1 if($temp+$i < $inputfieldmax) then $function[$temp+$i]=$gaDropFiles[$i] GUICtrlSetData($inputfield[$temp+$i], $function[$temp+$i]) endif next endif if $msg== $GUI_EVENT_CLOSE then $done= 1 WEnd Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize) ReDim $gaDropFiles[$i+1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next EndFunc Edited March 8, 2011 by songersoft Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
guinness Posted March 8, 2011 Share Posted March 8, 2011 (edited) With drag and drop files, I really need a way to parse the files dropped before they land on an input field.Have you searched for WM_DROPFILES in the Forum?Example 1: Example 2: Or a way to clear the input field before the drop takes place?GUICtrlSetData() of course, but I really think WM_DROPFILES will help you! Edited March 8, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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