blumi Posted October 22, 2013 Share Posted October 22, 2013 When I move a file from Explorer on the gui via Drag'n'Drop the file should be opened automaticly. For expample, I move a video file on the gui and the gui opens the file with vlc. Is this possible with autoit? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 22, 2013 Moderators Share Posted October 22, 2013 blumi,Yes. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blumi Posted October 22, 2013 Author Share Posted October 22, 2013 Sounds good. Can you tell me some key words I have to search for to realize it, that would help. ;-) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 22, 2013 Moderators Share Posted October 22, 2013 (edited) "drag + drop" yielded a number of results for me on the forum search. Edited October 22, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 22, 2013 Moderators Share Posted October 22, 2013 blumi,Search the forum for $WS_EX_ACCEPTFILES & $GUI_DROPACCEPTED - they are the styles you need to apply to your GUI and the relevant controls - and @GUI_DragFile - which will hold the filename. Then you can look to Run or ShellExecute to execute the file. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blumi Posted October 23, 2013 Author Share Posted October 23, 2013 Okay, found some nice code. Drag & Drop the file on the input field on the gui it works fine. Did some tests without the input field but didn't work. How to handle a gui without an input field where I can drag & drop the file on it? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> Opt("GUIOnEventMode", 1) GUICreate("Test GUI", 300, 100, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename") GUISetOnEvent($GUI_EVENT_CLOSE, '_exit') GUICtrlCreateInput('', 28, 20, 240, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) Func On_Drop_InFilename() GUICtrlSetData(@GUI_DropId, @GUI_DragFile) MsgBox(0, "test", "file: " & @GUI_DragFile) EndFunc ;==>On_Drop_InFilename Func _exit() Exit 1 EndFunc ;==>_exit Do Sleep(10) Until 0 Link to comment Share on other sites More sharing options...
wraithdu Posted October 23, 2013 Share Posted October 23, 2013 That's a bit more complicated, as you'll have to deal with window messages directly. You'll want to search for the WM_DROPFILES message and the DragQueryFile / DragFinish functions. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 23, 2013 Moderators Share Posted October 23, 2013 blumi,Here is some code to do what you want - credit goes to ProgAndy who showed me how to do it: #include <Array.au3> #include <GUIConstantsEx.au3> Global $gaDropFiles[1], $iDropItem = -1 Global $WM_DROPFILES = 0x233 GUICreate("DropIt", 241, 312, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $FILES_DROPPED = GUICtrlCreateDummy() GUISetState() GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC') While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $FILES_DROPPED $aFiles = $gaDropFiles _ArrayDisplay($aFiles) EndSwitch WEnd Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 0) ReDim $gaDropFiles[$nAmt[0]] 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, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize) $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next GUICtrlSendToDummy($FILES_DROPPED, $nAmt[0]) EndFunc ;==>WM_DROPFILES_FUNCM23 jaberwacky 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted October 23, 2013 Share Posted October 23, 2013 expandcollapse popup#include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> Global $__aDropFiles = 0 Example() Func Example() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) ; Create a label that is transparent which will accept 'drop' events. GUICtrlCreateLabel('', 0, 0, 500, 500) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED If $__aDropFiles[0] > 0 Then _ArrayDisplay($__aDropFiles) EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam Switch $iMsg Case $WM_DROPFILES Local Const $aReturn = _WinAPI_DragQueryFileEx($wParam) If UBound($aReturn) Then $__aGUIDropFiles = $aReturn Else Local Const $aError[1] = [0] $__aGUIDropFiles = $aError EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES If you have the latest AutoIt beta, then this is the way... 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...
kylomas Posted October 23, 2013 Share Posted October 23, 2013 blumi, If you are not doing anything else with the gui it can be this simple... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> Opt("GUIOnEventMode", 1) GUICreate("Test GUI", 300, 100, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename") GUISetOnEvent($GUI_EVENT_CLOSE, '_exit') GUICtrlCreatelabel('',0, 0, 300, 100) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) Func On_Drop_InFilename() GUICtrlSetData(@GUI_DropId, @GUI_DragFile) MsgBox(0, "test", "file: " & @GUI_DragFile) EndFunc ;==>On_Drop_InFilename Func _exit() Exit 1 EndFunc ;==>_exit Do Sleep(10) Until 0 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
topten Posted March 11, 2016 Share Posted March 11, 2016 On 23.10.2013 at 4:56 PM, Melba23 said: blumi, Here is some code to do what you want - credit goes to ProgAndy who showed me how to do it: #include <Array.au3> #include <GUIConstantsEx.au3> Global $gaDropFiles[1], $iDropItem = -1 Global $WM_DROPFILES = 0x233 GUICreate("DropIt", 241, 312, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $FILES_DROPPED = GUICtrlCreateDummy() GUISetState() GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC') While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $FILES_DROPPED $aFiles = $gaDropFiles _ArrayDisplay($aFiles) EndSwitch WEnd Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 0) ReDim $gaDropFiles[$nAmt[0]] 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, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize) $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next GUICtrlSendToDummy($FILES_DROPPED, $nAmt[0]) EndFunc ;==>WM_DROPFILES_FUNC M23 Is it possible to do the same with GUIOnEventMode? Link to comment Share on other sites More sharing options...
AutoBert Posted March 11, 2016 Share Posted March 11, 2016 Yes, just use GuiCtrlSetOnevent and GuiSetOnEvent instead or GuiGetMsg. As a Univerlisat you should know what must be done to get it working in OnEventMode. Link to comment Share on other sites More sharing options...
topten Posted March 11, 2016 Share Posted March 11, 2016 Great, thanx AutoBert I didnt notice that $FILES_DROPPED becomes a control there, so, I can use GuiCtrlSetOnevent $FILES_DROPPED = GUICtrlCreateDummy() 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