Trong Posted March 27, 2015 Share Posted March 27, 2015 (edited) Func wm_dropfiles_func($hwnd, $msgid, $wparam, $lparam) Local $nsize, $pfilename Local $namt = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", -1, "ptr", 0, "int", 255) For $i = 0 To $namt[0] - 1 $nsize = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", $i, "ptr", 0, "int", 0) $nsize = $nsize[0] + 1 $pfilename = DllStructCreate("wchar[" & $nsize & "]") DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", $i, "int", DllStructGetPtr($pfilename), "int", $nsize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pfilename, 1) $pfilename = 0 Next EndFunc ;==>wm_dropfiles_func wm_dropfiles_func Errror: +>AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0 Keyboard:00000409 OS:WIN_81/ CPU:X64 OS:X64 Environment(Language:0409) AutoIt v3.3.12.0 Code Example: expandcollapse popupOpt("MustDeclareVars", 1) Opt("TrayAutoPause", 0) Global Const $WS_EX_ACCEPTFILES = 0x00000010 Global Const $WS_EX_TOPMOST = 0x00000008 Global Const $WS_EX_WINDOWEDGE = 0x00000100 Global Const $GUI_EVENT_CLOSE = -3 Global Const $GUI_EVENT_MINIMIZE = -4 Global Const $GUI_EVENT_RESTORE = -5 Global Const $GUI_EVENT_MAXIMIZE = -6 Global Const $GUI_EVENT_PRIMARYDOWN = -7 Global Const $GUI_EVENT_PRIMARYUP = -8 Global Const $GUI_EVENT_SECONDARYDOWN = -9 Global Const $GUI_EVENT_SECONDARYUP = -10 Global Const $GUI_EVENT_MOUSEMOVE = -11 Global Const $GUI_EVENT_RESIZED = -12 Global Const $GUI_EVENT_DROPPED = -13 Global Const $gui_dropaccepted = 8 Global Const $wm_dropfiles = 563 Global Const $CodeBy="Dao Van Trong - Trong.TK" Global $gaDropFiles[1],$sListFileDrop,$sDropsAccept=True ;~ Global Const $GUI_SS_DEFAULT_GUI = BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) Global $Form1 = GUICreate("Form1", 448, 116, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) Global $Pic1 = GUICtrlCreatePic("C:\Users\TrOnG\Desktop\Image.jpg", 0, 0, 112, 112) GUICtrlSetState(-1, $gui_dropaccepted) Global $sListProcessFile = GUICtrlCreateList("", 112, 1, 333, 112) GUICtrlSetState(-1, $gui_dropaccepted) GUISetState(@SW_SHOW) GUIRegisterMsg($wm_dropfiles, "wm_dropfiles_func") While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $gui_event_dropped $sDropsAccept = False Local $i, $ntotal = UBound($gaDropFiles) - 1 For $i = 0 To $ntotal $sListFileDrop &= "|" & $gaDropFiles[$i] Next GUICtrlSetData($sListProcessFile, $sListFileDrop) $sListFileDrop = "" $sDropsAccept = True Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func wm_dropfiles_func($hwnd, $msgid, $wparam, $lparam) If $sDropsAccept Then Local $nsize, $pfilename Local $namt = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", -1, "ptr", 0, "int", 255) For $i = 0 To $namt[0] - 1 $nsize = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", $i, "ptr", 0, "int", 0) $nsize = $nsize[0] + 1 $pfilename = DllStructCreate("wchar[" & $nsize & "]") DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wparam, "int", $i, "int", DllStructGetPtr($pfilename), "int", $nsize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pfilename, 1) $pfilename = 0 Next EndIf EndFunc ;==>wm_dropfiles_func Edited March 27, 2015 by Trong Regards, Link to comment Share on other sites More sharing options...
Solution guinness Posted March 27, 2015 Solution Share Posted March 27, 2015 Before someone posts some outdated code, why not use _WinAPI_DragAcceptFiles() and _WinAPI_DragQueryFileEx()? Check the help file. Trong 1 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...
Trong Posted March 27, 2015 Author Share Posted March 27, 2015 Thanks: guinness Regards, Link to comment Share on other sites More sharing options...
guinness Posted March 27, 2015 Share Posted March 27, 2015 You're welcome. Trong 1 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