Chimaera Posted May 5, 2015 Share Posted May 5, 2015 I was thinking about a drop area on a gui for a file possibly rar fileCan i capture the filename from a drop area when the file is dropped on it?Does it require a special button/code or something to do it?Are there any limitations?I was going to do the normal popup box to choose the file but i wondered if a drop area might be ok for the same thing. If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Xandy Posted May 5, 2015 Share Posted May 5, 2015 (edited) I remember I setup some gui input controls to accept drag and drop (to store filename and or paths). I can find the code if that is something you're interested in.This looks like an example of something that might work, it's been a long time since I've done anything like this. Edited May 5, 2015 by Xandy 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 May 6, 2015 Share Posted May 6, 2015 (edited) Did you search? Because honestly you're not the first person to ask this question and surely won't be the last.In spite of that, I will create some clean workable code for you. A simple drag and drop file(s) on a label using a custom API. See the Example() function of how to use and please please please read the comments.expandcollapse popup#include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> ; Internal array, DO NOT USE directly. Instead call GetDropFiles() & IsValidDrop() Global $g_aDropFiles[0] Example() Func Example() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) ; IMPORTANT: If the system is using limited access rights If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) ; Create a label that is transparent which will accept 'drop' events. GUICtrlCreateLabel('Drop Files Here...', 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) Local $aDropped = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED ; This always returns a valid array regardless of an error $aDropped = GetDropFiles() ; Was a valid drop? If IsValidDrop() Then _ArrayDisplay($aDropped) EndIf ; Write the list of files to the console For $i = 1 To UBound($aDropped) - 1 ; $i is 1, because we need to skip the count in the first element. By iterating over the array this way, we avoid "out of bounds" errors ConsoleWrite('File ' & $i & ' => ' & $aDropped[$i] & @CRLF) Next ; Empty line ConsoleWrite(@CRLF) EndSwitch WEnd ; Clean up the resources GUIDelete($hGUI) EndFunc ;==>Example ; Get the dropped list of files. NOTE: Destroys the global varibale on return Func GetDropFiles() Local Const $aEmpty[1] = [0] ; Empty array Local $aReturn = $g_aDropFiles $g_aDropFiles = $aEmpty ; Destroy the global variable with the empty array Return $aReturn EndFunc ;==>GetDropFiles ; Use to determine if the drop was valid Func IsValidDrop() Return UBound($g_aDropFiles) > 0 EndFunc ;==>IsValidDrop Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam If $iMsg = $WM_DROPFILES Then $g_aDropFiles = _WinAPI_DragQueryFileEx($wParam) If Not UBound($g_aDropFiles) Then Local Const $aError[1] = [0] ; Empty array $g_aDropFiles = $aError ; Set with the empty array EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES Edited May 7, 2015 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...
guinness Posted May 6, 2015 Share Posted May 6, 2015 (edited) I remember I setup some gui input controls to accept drag and drop (to store filename and or paths). I can find the code if that is something you're interested in.This looks like an example of something that might work, it's been a long time since I've done anything like this.The code is outdated, as the functions are included in the UDF library. Therefore re-use code, don't create new. Edited May 6, 2015 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...
ViciousXUSMC Posted May 6, 2015 Share Posted May 6, 2015 (edited) I would not mind perfecting this as well.I use a lot of "right click" scripts and that works fine but for some things drag and drop would work great too so that I do not overpopulate the right click context menus. Edit:For a single item drag/drop seems I got enough to get done what I would need to get done.#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) $Button1 = GUICtrlCreateButton("GO!", 192, 24, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ExitLoop EndSwitch WEnd MsgBox(0, "", GUICtrlRead($Input1))Next step for me would be find how to remove the "OK" button and have it exit loop when the file is dragged. I assume a GUICtrlRead($Input1) <> "Input1" Then ExitLoop would work. Edit: yes that works, now how to keep the GUI open so I can drag more than one file without re-launching the gui Edited May 6, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted May 6, 2015 Share Posted May 6, 2015 This seems to work do not know if its a terrible way to code it.expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) ;Do Not Need Button Anylonger ;$Button1 = GUICtrlCreateButton("GO!", 192, 24, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Loop() Func Loop() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Case $Button1 ;ExitLoop EndSwitch If GUICtrlRead($Input1) <> "Input1" Then ExitLoop WEnd ;Action to take on file each time dragged, in this case just a msgbox MsgBox(0, "", GUICtrlRead($Input1)) GUICtrlSetData($Input1, "Input1") Loop() EndFunc Link to comment Share on other sites More sharing options...
guinness Posted May 6, 2015 Share Posted May 6, 2015 Well it could be better. At least you're using named constants instead of magic values. 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...
Chimaera Posted May 6, 2015 Author Share Posted May 6, 2015 (edited) Well this is lively i was asking questions but thanks for the excellent answersOne question remains unanswered thoughDoes a dropbox have limitaions? is there a max amount of files it can handle? or size etcknowing AutoIt it will prob be large but i was curious.Being as im using it to isolate one file from many after they are dropped it probably wont matter to me anyway but i was just curiousive started like this using guinness exampleexpandcollapse popup#include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <StaticConstants.au3> #include <File.au3> ; For Pathsplit ; Internal array, DO NOT USE directly. Instead call GetDropFiles() & IsValidDrop() Global $g_aDropFiles[0] Example() Func Example() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" ; Create a label that is transparent which will accept 'drop' events. GUICtrlCreateButton('Drop Files Here', 100, 100, 300, 300) GUICtrlSetBkColor(-1, 0xE0FFFF) ;~ GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') GUISetState(@SW_SHOW, $hGUI) Local $aDropped = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED $aDropped = GetDropFiles() ; This always returns a valid array regardless of an error If IsValidDrop() Then _ArraySort($aDropped); Sort the array so the first file is at the top _ArrayDisplay($aDropped) $FirstFile = $aDropped[1]; Select only the first file for the name ConsoleWrite($FirstFile & @CRLF) $FileName = _PathSplit($FirstFile,$sDrive, $sDir, $sFilename, $sExtension) ; split the name from the path EndIf ; Write the list of files to the console ;~ For $i = 1 To UBound($aDropped) - 1 ; $i is 1, because we need to skip the count in the first element. By iterating over the array this way, we avoid "out of bounds" errors ;~ ConsoleWrite('File ' & $i & ' => ' & $aDropped[$i] & @CRLF) ;~ Next ;~ ConsoleWrite(@CRLF) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example ; Get the dropped list of files Func GetDropFiles() Return $g_aDropFiles EndFunc ;==>GetDropFiles ; Use to determine if the drop was valid Func IsValidDrop() Return UBound($g_aDropFiles) > 0 EndFunc ;==>IsValidDrop Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam If $iMsg = $WM_DROPFILES Then $g_aDropFiles = _WinAPI_DragQueryFileEx($wParam) If Not UBound($g_aDropFiles) Then Local Const $aError[0] ; Empty array $g_aDropFiles = $aError ; Set with the empty array EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILESthen i shall use the pieces to determine files i need etcEarly days i shall get time later in the week to start working on it Many thanks Edited May 7, 2015 by Chimaera Updated as per guinness request If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
kylomas Posted May 7, 2015 Share Posted May 7, 2015 @ViciousXUSMC,F.Y.I. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) ;Do Not Need Button Anylonger ;$Button1 = GUICtrlCreateButton("GO!", 192, 24, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Loop() ;Func Loop() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $gui_event_dropped ; <--------- instead of reading the input control just monitor the drop event MsgBox(0, "", GUICtrlRead($Input1)) GUICtrlSetData($Input1, "Input1") ;Case $Button1 ;ExitLoop EndSwitch ;If GUICtrlRead($Input1) <> "Input1" Then ExitLoop WEnd ;Action to take on file each time dragged, in this case just a msgbox ;MsgBox(0, "", GUICtrlRead($Input1)) ;GUICtrlSetData($Input1, "Input1") ;Loop() ;EndFunc ;==>Loopkylomas ViciousXUSMC 1 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...
guinness Posted May 7, 2015 Share Posted May 7, 2015 The only limitation is how many elements an array can have. Check the help file for the limits. 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...
guinness Posted May 7, 2015 Share Posted May 7, 2015 Oh and I guess you have a small test script, therefore could you post it all instead of a small snippet. It's just that the code you posted makes no sense to a new user, without an overall view of the code beforehand. Plus think how you would feel if you came across a post where you knew it was useful, but a huge chunk of code was missing.This is why I always post runnable code, as it helps everyone to understand. Thanks. kylomas 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...
ViciousXUSMC Posted May 7, 2015 Share Posted May 7, 2015 (edited) @ViciousXUSMC,F.Y.I. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) ;Do Not Need Button Anylonger ;$Button1 = GUICtrlCreateButton("GO!", 192, 24, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Loop() ;Func Loop() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $gui_event_dropped ; <--------- instead of reading the input control just monitor the drop event MsgBox(0, "", GUICtrlRead($Input1)) GUICtrlSetData($Input1, "Input1") ;Case $Button1 ;ExitLoop EndSwitch ;If GUICtrlRead($Input1) <> "Input1" Then ExitLoop WEnd ;Action to take on file each time dragged, in this case just a msgbox ;MsgBox(0, "", GUICtrlRead($Input1)) ;GUICtrlSetData($Input1, "Input1") ;Loop() ;EndFunc ;==>LoopkylomasHey thanks, that is much cleaner. Such a big difference in can make just to know a few extra pieces of information about AutoIT. Also I was having brain malfunction for some reason yesterday trying to think how to make the loop repeat so I was self referencing a function and I think thats a bad bad idea usually. Even my way it could have been cleaner like this.expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Case $Button1 ;ExitLoop EndSwitch If GUICtrlRead($Input1) <> "" Then ;Action to take on file each time dragged, in this case just a msgbox $data = GUICtrlRead($Input1) $aSplitData = StringSplit($data, "|", 2) If Not IsArray($aSplitData) Then MsgBox(0, "", GUICtrlRead($Input1)) Else ;_ArrayDisplay($aSplitData) For $i = 0 to UBound($aSplitData) - 1 MsgBox(0, "", $aSplitData[$i]) Next EndIf GUICtrlSetData($Input1, "") EndIf WEnd My Ultimate end result was this however.#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 89, 192, 124, -1, $WS_EX_ACCEPTFILES) ;0x00000010 $Input1 = GUICtrlCreateInput("", 40, 32, 121, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;8 $Label1 = GUICtrlCreateLabel("Drag Here!", 72, 8, 56, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED ;Action to take on file each time dragged, in this case just a msgbox $data = GUICtrlRead($Input1) $aSplitData = StringSplit($data, "|", 2) If Not IsArray($aSplitData) Then MsgBox(0, "", GUICtrlRead($Input1)) Else ;_ArrayDisplay($aSplitData) For $i = 0 to UBound($aSplitData) - 1 MsgBox(0, "", $aSplitData[$i]) Next EndIf GUICtrlSetData($Input1, "") EndSwitch WEndEdit: And yeah when I saw what happens to my msgbox when dragging in multiple files it was not too hard to figure out how to toss that into an array for a multi-drag & drop (plus the help file example was great) Edited May 7, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
kylomas Posted May 7, 2015 Share Posted May 7, 2015 @Chimaera, ViciousXUSC,Dropped files are always delimited with a separator char, even if only one is dropped. Therefore the code can be simplified like this#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> local $gui010 = guicreate('Drop Example',200,100) guisetstyle(-1,$WS_EX_ACCEPTFILES,$gui010) local $inp010 = guictrlcreateinput('',10,30,180,20) guictrlsetstate($inp010, $GUI_DROPACCEPTED) local $inp020 = guictrlcreateinput('',10,70,180,20) guictrlsetstate($inp020, $GUI_DROPACCEPTED) guisetstate() local $aFiles while 1 switch guigetmsg() case $gui_event_close Exit case $gui_event_dropped ConsoleWrite('Files dropped on ' & ( @GUI_DropId = $inp010 ? '$inp010:' & @CRLF : '$inp020:' & @CRLF )) $aFiles = stringsplit(guictrlread(@GUI_DROPID),'|',3) for $1 = 0 to ubound($aFiles) - 1 ConsoleWrite(@tab & $aFiles[$1] & @CRLF) next EndSwitch WEndkylomas 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...
guinness Posted May 7, 2015 Share Posted May 7, 2015 (edited) @All, Perhaps everyone should analyse this code and see what I changed. Plus my version above is better as it's not limited to input controls only.expandcollapse popup#include <GUIConstantsEx.au3> #include <StringConstants.au3> #include <WindowsConstants.au3> ; Improved by using the correct casing for constants as well as best practices in AutoIt Example() Func Example() Local $hGUI = GUICreate('Drop Example', 200, 100, -1, -1, -1, $WS_EX_ACCEPTFILES) ; Set the ExStyle on GUI creation Local $idInput1 = GUICtrlCreateInput('', 10, 30, 180, 20) GUICtrlSetState($idInput1, $GUI_DROPACCEPTED) Local $idInput2 = GUICtrlCreateInput('', 10, 70, 180, 20) GUICtrlSetState($idInput2, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW, $hGUI) Local $aFiles = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ; Don't Exit, ExitLoop Case $GUI_EVENT_DROPPED ConsoleWrite('Files dropped on ' & _ '$idInput' & ((@GUI_DropId == $idInput1) ? '1' : '2') & @CRLF) ; Proper usage $aFiles = StringSplit(GUICtrlRead(@GUI_DropId), '|', $STR_NOCOUNT) ; No need for entire split as it's a pipe char For $i = 0 To UBound($aFiles) - 1 ; Common practice to use $i NOT $l ConsoleWrite(@TAB & $aFiles[$i] & @CRLF) Next EndSwitch WEnd GUIDelete($hGUI) ; Tidy up the GUI resources EndFunc ;==>ExampleI admit we all have our unique styles when it comes to programming, but in the real world when you work as a developer you have to meet the common standards used across all languages such as i being used as an iterator variable. Edited May 7, 2015 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...
guinness Posted May 7, 2015 Share Posted May 7, 2015 I have updated my code above. Thanks. 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 May 7, 2015 Share Posted May 7, 2015 (edited) Thank God I'm Retired!!! Edited May 7, 2015 by kylomas clarity 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...
guinness Posted May 7, 2015 Share Posted May 7, 2015 Thank God I'm Retired!!!Haha, okay! Now I understand 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...
Chimaera Posted May 7, 2015 Author Share Posted May 7, 2015 (edited) Using guinness earlier code i have moved on to hereexpandcollapse popup#include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <StaticConstants.au3> #include <File.au3> ; For Pathsplit ; Internal array, DO NOT USE directly. Instead call GetDropFiles() & IsValidDrop() Global $g_aDropFiles[0] Example() Func Example() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" ; Create a label that is transparent which will accept 'drop' events. GUICtrlCreateButton('Drop Files Here', 100, 100, 300, 300) GUICtrlSetBkColor(-1, 0xE0FFFF) ;~ GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') GUISetState(@SW_SHOW, $hGUI) Local $aDropped = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED $aDropped = GetDropFiles() ; This always returns a valid array regardless of an error If IsValidDrop() Then _ArraySort($aDropped); Sort the array so the first file is at the top _ArrayDisplay($aDropped) ; <<<<<<<<<< error checking $FirstFile = $aDropped[1]; Select only the first file for the name $FileSplit = _PathSplit($FirstFile,$sDrive, $sDir, $sFilename, $sExtension) ; split the name from the path $sPath = $sDrive & $sDir ConsoleWrite('Path = ' & $sPath & @CRLF) ConsoleWrite('Drive = ' & $sDrive & @CRLF & 'Dir = ' & $sDir & @CRLF & 'Filename = ' & $sFilename & @CRLF & 'Extension = ' & $sExtension & @CRLF) ; <<<<<<<<<< error checking ;---------------------------------------- If $sExtension = '.par2' Or $sExtension = '.par3' Then Local $FindFiles = _FileListToArrayRec( $sPath, '*' & $sFilename & $sExtension, 1, 0) _ArrayDisplay($FindFiles, ".Par Files") If IsArray($FindFiles) Then For $i = 1 To $FindFiles[0] FileMove($sPath & $FindFiles[$i], $sPath & $sFilename & "\", 9) Sleep(100) Next EndIf ;~ _Repair() ElseIf $sExtension = '.rar' Then Local $FindFiles = _FileListToArrayRec( $sPath, '*' & StringTrimRight($sFilename, 2) & '*', 1, 0) _ArrayDisplay($FindFiles, ".Rar Files") If IsArray($FindFiles) Then For $i = 1 To $FindFiles[0] FileMove($sPath & $FindFiles[$i], $sPath & $sFilename & "\", 9) Sleep(100) Next EndIf ;~ straight to extract ElseIf $sExtension = '.zip' Or $sExtension = '.7z' Then Local $FindFiles = _FileListToArrayRec( $sPath, '*' & StringTrimRight($sFilename, 2) & '*', 1, 0) _ArrayDisplay($FindFiles, ".Zip/7z Files") If IsArray($FindFiles) Then For $i = 1 To $FindFiles[0] FileMove($sPath & $FindFiles[$i], $sPath & $sFilename & "\", 9) Sleep(100) Next EndIf ;~ straight to extract Else MsgBox(64, 'File Error', 'Unknown File Type') EndIf EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example ; Get the dropped list of files Func GetDropFiles() Return $g_aDropFiles EndFunc ;==>GetDropFiles ; Use to determine if the drop was valid Func IsValidDrop() Return UBound($g_aDropFiles) > 0 EndFunc ;==>IsValidDrop Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam If $iMsg = $WM_DROPFILES Then $g_aDropFiles = _WinAPI_DragQueryFileEx($wParam) If Not UBound($g_aDropFiles) Then Local Const $aError[0] ; Empty array $g_aDropFiles = $aError ; Set with the empty array EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILESSo its progressing slowly The only thing i cant quite work out is how to allow for the fact if they add 2 diff sets of archives at the same time.It finds both but it doesnt extract the diff sets to folders only the first one Edited May 7, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
guinness Posted May 7, 2015 Share Posted May 7, 2015 I updated GetDropFiles(). See above. 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 May 7, 2015 Share Posted May 7, 2015 @Guinness Haha, okay! Now I understand You know that I've always taken your advice. Some "real world" opinions for naming an iterator. 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...
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