am632 Posted April 2, 2019 Share Posted April 2, 2019 Hi Everyone, I'm using the following script to get files via drag & drop which which works fine, I'm just having the file names display in a msgbox at the moment as they will be passed to another command-line program later. expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <GuiConstants.au3> #include <FileConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIEx.au3> #include <Array.au3> #include <String.au3> ;Global Declaration Global $aDrop_List, $__aGUIDropFiles, $dropFile, $Main $Main = GUICreate("Main", 400, 400, -1, -1, $WS_POPUP, $WS_EX_ACCEPTFILES) GUISetBkColor(0x8a64e7, $Main) GUICtrlCreateLabel("Drop files here", 45, 11, 240, 23, -1, -1) GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI") GUICtrlSetColor(-1, "0xFFFFFF") GUICtrlSetBkColor(-1, "-2") Local Const $iDrop = GUICtrlCreatePic("Image\image.jpg", 100, 60, 100, 100, -1, -1) GUICtrlSetState($iDrop, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW, $Main) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED _DropFunc() EndSwitch WEnd #endregion 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 Func _DropFunc() Local $String = _ArrayToString($__aGUIDropFiles, " ", 1, UBound($__aGUIDropFiles) - 1) msgbox(0,"",$String) EndFunc The problem is the command line program I'm using doesn't support spaces in the file names so can anyone help me wrap each file name in quotes once they have been dropped in, or after the _ArrayToString function I think would work. I'm not even sure where to start with fixing this, The only thing I thought was to add quotes before and after the $string variable in the msgbox but this can only work if 1 file has been dropped in and not multiple files which is what I require. Any help would be greatly appreciated. Many Thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2019 Developers Share Posted April 2, 2019 Something like: msgbox(0,"",'"' & $String & '"') Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted April 2, 2019 Share Posted April 2, 2019 Local $String = '"' & StringReplace (_ArrayToString($__aGUIDropFiles, "|", 1),"|",'" "') & '"' Try this “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
am632 Posted April 4, 2019 Author Share Posted April 4, 2019 Hi Guys, Thanks for your suggestions, The second solution worked with a minor modification. Local $String = StringReplace (_ArrayToString($__aGUIDropFiles, "|", 1),"|",'" "') This now formats as follows which is exactly what I needed. "File 1.txt" "File 2 - copy.jpg" Many Thanks 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