Jump to content

Recommended Posts

I am trying to pass multi-file selections from Windows Explorer into the $CmdLine argument parameters array. For example, and these are not the literal program/project names, I can pass three full path file names via both Window's Run dialog and Terminal into the $CmdLine array, i.e, "c:\Dir\Program.exe" "D:\Test\file1.txt" "D:\Test\file2.txt" "D:\Test\file3.txt". When checked in the running program, $CmdLine index [1] has the correct value of 3, index [1] is correct with "D:\Test\file1.txt", index [2] with "D:\Test\file2.txt" and index [3] with "D:\Test\file3.txt". I get the same correct results in $CmdLine array when I start Program.exe with the same three file parameters using the Windows Terminal.

Also, I have added a HKEY_CLASSES_ROOT\*\shell\command key to the Window's registry. The registry entry is with a "C:\Program.exe" "%1" "$2" "%3" string value to allow for renaming file(s) from Windows Explorer via the right-click menu. With just one parameter placeholder, "%1" in the string value, a selected file will appear in $CmdLine. $CmdLine[0] is 1 and $Cmdline[1] contains the selected full path file name. Unfortunately, when I change the registry string value to include two more passing arguments, "%2" "%3", $CmdLine[0] =3 (as it should since three file path names are passed to Program.exe), $CmdLine[1] contains "D:\Test\file1.txt", but $CmdLine[2] and [3] are just empty strings.

It appears to me that Windows is not passing the second and third ("%2" and "%3") selected file's to Autoit, but just the first parameter "%1".

Is there some way that I can select more than one file in Window's Explorer and pass the full file paths into the $CmdLine array?

I know that AutoIt has the _WinAPI_GetOpenFileName function, but I would like to select files directly from Windows Explorer to bring into $CmdLine.

File Renaming Application 1.4.0.3.au3 Reg Key.reg

Edited by prizm1

Share this post


Link to post
Share on other sites

Hey,

Until someone comes up with a real solution, as a workaround what if you just pass one parameter %1 which holds all files with a placeholder char in between file names? Something you wouldn't expect (not allowed) in a filename and would be ok to pass. Then stringsplit and use as you wish.

 

Share this post


Link to post
Share on other sites
1 hour ago, GokAy said:

Until someone comes up with a real solution, as a workaround what if you just pass one parameter %1 which holds all files with a placeholder char in between file names? 

He’s not doing the passing - he wants to multi-select a bunch of files in windows explorer and have it run his program with the selected files as arguments, but apparently he’s only seeing the first one.


Code hard, but don’t hard code...

Share this post


Link to post
Share on other sites

Just place your app or shortcut to your app into %AppData%\Microsoft\Windows\SendTo

Right click file(s) and SendTo app

Example compile the following to SendTo path as CmdLines.exe

Right click file(s) » Send to » CmdLines.exe, it should display a list of all the files.

#include <Array.au3>
_ArrayDisplay($CmdLine)

 

Share this post


Link to post
Share on other sites
1 hour ago, Subz said:

Just place your app or shortcut to your app into %AppData%\Microsoft\Windows\SendTo

Right click file(s) and SendTo app

Example compile the following to SendTo path as CmdLines.exe

Right click file(s) » Send to » CmdLines.exe, it should display a list of all the files.

#include <Array.au3>
_ArrayDisplay($CmdLine)

 

Interesting as a work-around, Subz. Thanks. All three files in my test run seems to make it to $CmdLine via the SendTo approach. I don't know why the Window's registry approach passes only the first placeholder file path argument although $CmdLine[3] contains the correct number of placeholder arguments passed. I can run the identical string arguments via Window's Terminal and the Run command app with success. There must be some additional registry syntax required in addition to simply listing the placeholders after the compiled executable, ex., "C:\Dir\Program.exe" "%1" "%2" "%3". I would prefer the registry approach, though, if I could find a solution. It is a cleaner looking end-user approach to using the program.

Share this post


Link to post
Share on other sites

Maybe these will help then?

https://stackoverflow.com/questions/8635845/passing-multiple-parameters-through-registry

https://stackoverflow.com/questions/1826791/how-to-pass-in-multiple-file-folder-paths-via-a-right-click-event-verb-to-an-e

Same problem as yours, and only workaround seems like SubZ provided (32767 character command line limit). The real answer is writing a Shell Extension.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By lonardd
      Hi
      I have to run an executable with a parameter preceded by a /, like this:
      c:\myfolder\Tools\AutomaticRun\myexe.EXE /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml")
      I tried both this:
      $iReturn = RunWait ("c:\myfolder\Tools\AutomaticRun\myexe.EXE"," /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml")
      and using COMSPEC as per some posted suggestions on this forum:
      Run(@comspec & ' /c "c:\myfolder\Tools\AutomaticRun\myexe.EXE" /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml')
      They both seem to fail.
      Can you please tell me what I'm doing wrong?
      Thanks
      Dave
       
    • By Skysnake
      Hi
      Problem is this
      myscript -p <zumerkelen> -x something else myscript is my AutoIt compiled CUI.  
      -p <> is first param - fails, see below
      -x [text] second param, works.
      When I run this with the param enclosed in <> I get the response
      The syntax of the command is incorrect.
      Experimentation indicates that the <> tags are the problem.
      _ArrayDisplay($CmdLine, "1 Array") MsgBox(16, "1 Raw", $CmdLineRaw) The problem is with the reading of the command line.  It fails BEFORE it gets into the variables...

      I am not dealing with AutoIt, or even my own command line, this is legacy software.  It seems that AutoIt "interprets" the <> before loading the command line...  I need to be able to read that as text without it being interpreted.
      The only part I can control is my script, the myscript, which I can change at will.
      The standard command line functions appear all to interpret params on read.  I want those params read raw.   If I could just get that as a string it would be fine.
      Where to look?
      Skysnake
       
    • By Jefrey
      I've ported these two functions from PHP to AU3 to work with URLs.
      Made them for those who work with libraries like HTTP.au3 (not the one I coded), that needs passing the server domain, path, etc., instead of the full URL.
      Grab the lib here.
      ParseURL( $sURL )
      Parses the URL and splits it into defined parts. Returns an array:
      [0] = Full URL (same as $sURL) [1] = Protocol (i.e.: http, https, ftp, ws...) [2] = Domain [3] = Port (or null if not specified) [4] = Path (or null if not specified) [5] = Query string (everything after the ? - or null if not specified) Example:
      $aExample = ParseURL("https://google.com:8080/?name=doe") MsgBox(0, "Test", "URL: " & $aExample[0] & @CRLF & _ "Protocol: " & $aExample[1] & @CRLF & _ "Domain: " & $aExample[2] & @CRLF & _ "Port: " & $aExample[3] & @CRLF & _ "Path: " & $aExample[4] & @CRLF & _ "Query string: " & $aExample[5])  
      ParseStr( $sStr )
      Parses a query string (similar to the [5] of the previous function) and returns a multidimensional array, where:
      [0][0] = number of variables found [0][1] = ununsed [1][0] = key name of the first variable [1][1] = first variable value (already URL decoded) [n][0] = key name of the nth variable [n][1] = nth variable value (already URL decoded) Example:
      include <Array.au3> ; need only to do _ArrayDisplay, not needed by the lib _ArrayDisplay(ParseStr("foo=bar&test=lol%20123")) #cs Result is: [0][0] = 2 [0][1] = ununsed [1][0] = foo [1][1] = bar [2][0] = test [2][1] = lol 123 #ce Feel free to fork!
    • By Eddi96
      Hello guys!
      #include <Array.au3> #include <File.au3> $iBenutzername = $Var_cmdline ; I need this to be the variable given as a parameter. ; I've read alot about CmdLine but can't think of a way to define a variable with it ; I hope you have an Idea on how to do it! Much love <3 Global $sFile = "C:\GTScript\query.txt" Global $aUsers _FileReadToArray($sFile, $aUsers, $FRTA_NOCOUNT) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) For $i = 0 To UBound($aUsers) - 1 $aSplit = StringRegExp($aUsers[$i][0], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) For $j = 0 To UBound($aSplit)-1 $aUsers[$i][$j] =$aSplit[$j] Next $aUsers[$i][0]=StringReplace($aUsers[$i][0],'>','') Next $sUser=$iBenutzername Func _FindUserID($aArray,$sSearch) Local $iRow=_ArraySearch($aArray,$sUser) If @error Then Return SetError(@error,-1,'') Local $sID=$aArray[$iRow][2] Return SetError(0,$iRow,$sID) EndFunc MsgBox(64,'Searcher UserID '&$sUser,_FindUserID($aUsers,$sUser))  
    • By Skysnake
      Hi Everyone
      I want to have a GUI, but which will accept command line options on launch.
      So, the commanline would look something like
      myAPP.EXE -bigfont -bigicon
      where myAPP.EXE would be the name of the AutoIt EXE, and the -bigfont & -bigicon items represent optional command line parameters with which the EXE starts.
      I am not looking at creating a CUI.  This is GUI, but with startup command line parameters.  These command line parameters would only be read once, during start up of the EXE.
      I have searched the forum, no luck.  What I did find was this commented by Water: https://www.autoitscript.com/forum/topic/138754-adding-command-line-parameter/
      Should I start the GUI EXE as normal, and then first possible opportunity read the command line? Is that the way to go?
      Thanks in advance
×
×
  • Create New...