BartvanBeek Posted October 15, 2008 Share Posted October 15, 2008 (edited) Hi, When I select two or more files in the File Explorer of Windows and click on "Open" I want to know all the selected files i've selected. My code is: MsgBox(0,"Message","Script Started") IF $CmdLine[0] > 0 Then For $i = 1 to $CmdLine[0] MsgBox(0,"Selected File",$CmdLine[$i]) Next EndIf With one file it goes fine, but more files, I don't get the message "Script Started" (line 1 in my script). The windows setting is for example: "D:\My Program.exe" "%1" (in Folder Options > File Types) How do I solve this problem? Thanks! Edited October 16, 2008 by BartvanBeek Link to comment Share on other sites More sharing options...
YourSpace Posted October 15, 2008 Share Posted October 15, 2008 (edited) here you go MsgBox(0,"Message","Script Started") IF ubound($CmdLine)-1 > 0 Then For $i = 1 to ubound($CmdLine) -1 MsgBox(0,"Selected File",$CmdLine[$i]) Next EndIf im pretty sure that should work. Edited October 15, 2008 by YourSpace Link to comment Share on other sites More sharing options...
Varian Posted October 16, 2008 Share Posted October 16, 2008 Helpfile easily shows that $CmdLineRaw returns all the parameters Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 Helpfile easily shows that $CmdLineRaw returns all the parametersIt also says it returns all parameters on one line so it may be easier to open the files with $CmdLine. I think 63 parameters is enough for most apps. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 16, 2008 Developers Share Posted October 16, 2008 Don't think the people responded understand the question. I get when I set the compiled script to run when "Open" is selected for my ".tst" extension the following: My test script runs as many times as the number of files selected. Using WinXP sp3 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...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 That honestly makes sense. If you have a file extension associated with a program the default behavior would be to open one instance for each file. If you want your program to open all of them you'd probably have to change your code a bit. <--- If I understood Jos's interpretation correctly. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
BartvanBeek Posted October 16, 2008 Author Share Posted October 16, 2008 Don't think the people responded understand the question. I get when I set the compiled script to run when "Open" is selected for my ".tst" extension the following: My test script runs as many times as the number of files selected. Using WinXP sp3 Jos Right, that's the problem. How to solve this? I want to open 2 files in one exe. not each file in an exe. I select and open 2 files like this: Link to comment Share on other sites More sharing options...
BartvanBeek Posted October 17, 2008 Author Share Posted October 17, 2008 Can anybody help me please? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 17, 2008 Developers Share Posted October 17, 2008 I doubt this can be changed since this is an Explorer functions. Do you need to do this from Explorer or could you also use the autoit3 build in FIles select option ? 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...
j0linus Posted October 18, 2008 Share Posted October 18, 2008 You could use the SendTo Menu. Compile your script and copy it to "%USERPROFILE%\SendTo". (shortcut to compiled script also works) In Explorer select your files and click your script in the SendTo Menu - it should work. Link to comment Share on other sites More sharing options...
BartvanBeek Posted October 20, 2008 Author Share Posted October 20, 2008 I doubt this can be changed since this is an Explorer functions. Do you need to do this from Explorer or could you also use the autoit3 build in FIles select option ?JosI need to do this from the Explorer. How to change this in Explorer? @j0linus: Thanks for reply. I can't explain it to the end users to use my program with the 'Send-To menu'. Link to comment Share on other sites More sharing options...
mikiutama Posted October 20, 2008 Share Posted October 20, 2008 this depends on the program that opens the file if you're using notepad++ (and make it the default for opening text), it has tabbed setting that can open simultaneous files in one .exe just use shellexecute.. MsgBox(0,"Message","Script Started") IF ubound($CmdLine)-1 > 0 Then For $i = 1 to ubound($CmdLine) -1 ShellExecute($CmdLine[$i]) Next EndIf Link to comment Share on other sites More sharing options...
Developers Jos Posted October 20, 2008 Developers Share Posted October 20, 2008 I need to do this from the Explorer. How to change this in Explorer? @j0linus: Thanks for reply. I can't explain it to the end users to use my program with the 'Send-To menu'.As I said: To my knowledge its the way Explorer works...only thing I could think of is that the script you write and is shelled by Explorer multiple times is monitoring for a short while for other instances and you let one of the instances receive all information of the other instances. ( just thinking out loud without having tested any of it )this depends on the program that opens the fileif you're using notepad++ (and make it the default for opening text), it has tabbed setting that can open simultaneous files in one .exejust use shellexecute..Don't think you understand the challenge at hand. 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...
Developers Jos Posted October 20, 2008 Developers Share Posted October 20, 2008 (edited) This is a quick and dirty example of what I was thinking of: #NoTrayIcon #include<file.au3> #include<misc.au3> ; If $CmdLine[0] = 0 then Exit ; Test for first instance If _Singleton("MyTestScript",1) Then ; save Information to file For $i = 1 To $CmdLine[0] FileWriteLine(@tempdir & "\test.txt",$CmdLine[$i]) Next ; wait for other instances to finish While 1 $inst = ProcessList(@ScriptName) If $inst[0][0] < 2 Then ExitLoop sleep(10) WEnd Else ; save Information to file Sleep(50) For $i = 1 To $CmdLine[0] FileWriteLine(@tempdir & "\test.txt",$CmdLine[$i]) Next sleep(50) Exit EndIf ; Read all received parameters Global $cmdparams _FileReadToArray(@tempdir & "\test.txt",$cmdparams) For $x = 1 to $cmdparams[0] MsgBox(0,"Selected File",$cmdparams[$x]) Next FileDelete(@tempdir & "\test.txt") Edited October 20, 2008 by 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...
ProgAndy Posted October 20, 2008 Share Posted October 20, 2008 (edited) Well, explorer calls the App for EACH application Sp you have to handle this on your own, e.g. with WM_DROPFILESexpandcollapse popup#include <Memory.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> Global Const $RECEIVERGUID = FileGetShortName(@ScriptFullPath) & "d58c3e50-01b4-4a14-bfd4-d6f06fceb600" Global Const $WM_DROPFILES = 0x233 Global Const $tagDRAGINFO = "UINT uSize;" & _ ; /* init with sizeof(DRAGINFO) */ "int pt[2];" & _ ; POINT "int fND;" & _ "int WIDE;" ; statt den nächsten beiden Linien ;~ "ptr lpFileList;" & _ ; LPSTR ( UNICODE: LPWSTR ) ;~ "DWORD grfKeyState;" ; by Prog@ndy ; translated Delphi-Source from: http://www.delphipraxis.net/topic49148.html Func DropFilesOnWnd($AWnd, $AFiles) ;aFiles as CRLF splitted list Local $LInfoStruct = DllStructCreate($tagDRAGINFO) Local $LInfo Local $LRes;: Boolean; Local $LHGlobal;: Cardinal; $LRes = False; ;~ if copy(AFiles, length(AFiles), 1) <> #0 then $AFiles = StringReplace($AFiles, @CRLF, Chr(0)) & Chr(0); $LHGlobal = _MemGlobalAlloc(DllStructGetSize($LInfoStruct) + StringLen($AFiles) + 1,BitOR($GMEM_SHARE, $GMEM_MOVEABLE, $GMEM_ZEROINIT)); If $LHGlobal <> 0 Then $LInfo = _MemGlobalLock($LHGlobal); If $LInfo <> 0 Then $LInfoStruct = DllStructCreate($tagDRAGINFO, $LInfo) DllStructSetData($LInfoStruct, 1, DllStructGetSize($LInfoStruct)) Local $temp = DllStructCreate("char[" & StringLen($AFiles)+1 & "]",$LInfo+DllStructGetSize($LInfoStruct)) DllStructSetData($temp,1,$AFiles) ;~ DllStructSetData($LInfo, "lpFileList", DllStructGetPtr($temp)) DllStructSetData($LInfoStruct, 2, 20000,1) DllStructSetData($LInfoStruct, 2, -1234,2) $temp = "" $LInfoStruct = "" ;~ Move(AFiles[1], PChar(Cardinal(LInfo) + LInfo.uSize)^, length(AFiles)); _MemGlobalUnlock($LHGlobal); $LRes = _WinAPI_PostMessage($AWnd, $WM_DROPFILES, $LHGlobal, 0); EndIf If Not ($LRes) Then _ _MemGlobalFree($LHGlobal); EndIf ;~ end; Return $LRes; EndFunc ;==>DropFilesOnWnd Global $CMDLINEFILE = False If $CMDLINE[0] >= 1 Then $CMDLINEFILE = $CMDLINE[1] If $CMDLINEFILE And FileExists($CMDLINEFILE) Then If WinExists($RECEIVERGUID) Then $ret = DropFilesOnWnd(WinGetHandle($RECEIVERGUID), StringReplace($CMDLINEFILE, '"', "")) Exit Else ; nothing :) EndIf EndIf GUICreate($RECEIVERGUID, 1, 1, 0, 0) ; GUI to receive Dragdrop GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") $title = "accept filename dropped on listview" $GUI = GUICreate($title,-1,-1,-1,-1,-1,$WS_EX_ACCEPTFILES); $ListView = GUICtrlCreateListView("file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |How was it added?",10,10,380,200) GUISetState() If $CMDLINEFILE Then GUICtrlCreateListViewItem($CMDLINEFILE&"|CMD-Line -firstone",$ListView) while 1 $msg = GUIGetMsg() if $msg = -3 then exit WEnd ;Func copied from forum somewhere and modified Func WM_DROPFILES($hWnd, $Msg, $wParam, $lParam) Local $tDrop, $aRet, $iCount ; POINT check :) Local $POINT = DllStructCreate("int[2]") DllCall("shell32.dll", "int", "DragQueryPoint", "hwnd", $wParam, "ptr", DllStructGetPtr($POINT)) ;string buffer for file path $tDrop = DllStructCreate("char[260]") ;get file count $aRet = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "uint", -1, "ptr", DllStructGetPtr($tDrop), "int", DllStructGetSize($tDrop)) $iCount = $aRet[0] ;get file paths Local $CurInfo = GUIGetCursorInfo($GUI) If (IsArray($CurInfo) And $CurInfo[4] = $ListView) Then For $i = 0 To $iCount-1 $aRet = DllCall("shell32.dll", "int", "DragQueryFile","hwnd", $wParam,"uint", $i,"ptr", DllStructGetPtr($tDrop),"int", DllStructGetSize($tDrop)) GUICtrlCreateListViewItem(DllStructGetData($tDrop, 1)&"|DragDrop on LV",$ListView) Next ElseIf (DllStructGetData($POINT,1,1) = 20000 And DllStructGetData($POINT,1,2) = -1234 ) Then For $i = 0 To $iCount-1 $aRet = DllCall("shell32.dll", "int", "DragQueryFile","hwnd", $wParam,"uint", $i,"ptr", DllStructGetPtr($tDrop),"int", DllStructGetSize($tDrop)) GUICtrlCreateListViewItem(DllStructGetData($tDrop, 1)&"|CMD-Line",$ListView) Next EndIf ;finalize DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam) Return EndFuncTo try, compile and use a context menu entry like this:HKCR\.testext\testentry\Command -> (Default) = "X:\PATH\TO\SCRIPT.exe" "%l" Edited October 20, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
ProgAndy Posted October 22, 2008 Share Posted October 22, 2008 Well, did my example help? *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes 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