Jump to content

File association - open multiple


Recommended Posts

Hi all,

Sorry to have a question as my first post (usually I rtfm :D or search the forum :D ), but this time couldnt manage to find an answer :P .

Problem:

Ive associated my script (exe) with the file type I want to open and everything works fine when selecting only one file (right click -> Open). When selecting more than one file, I get my script separately executed for each one of them (every instance gets only one file as parameter). Ive tried using %L or %* instead of %1 (like some music players do) with no success.

Question

Is there a way to get all selected files at once? Ive noticed some people are using Explorers SendTo (though I don't know how they set it up) instead of Open but I guess it all comes down to the shell command associated.

Any workaround ideas appreciated.

Thx.

Link to comment
Share on other sites

%L is for long filenames. I may presume that %* may mean multiple parameters, not sure of that. So "%1" "%*" is probably multiple entries...

Send To is in your profile directory and is easier then setting up a registry entry for a parameter sent to a progam for startup then the registry, though pity M$ hides the folder.

Edited by MHz
Link to comment
Share on other sites

%L is for long filenames. I may presume that %* may mean multiple parameters, not sure of that. So "%1" "%*" is probably multiple entries...

Thx for your quick response.

I've tried "%1" "%*" and same problem (I get one instance for every file).

Send To is in your profile directory and is easier then setting up a registry entry for a parameter sent to a progam for startup then the registry, though pity M$ hides the folder.

I managed to set up the SendTo and it's working ... I will probably need both methods implemented as I would like to have the custom icons and double-click Open that comes with file association.

As it can be done without registry, it would be nice to make file association work with multiple files though.

RunWait(@ComSpec & ' /c ftype ' & $tmp_type & '=' & @ScriptFullPath &  ' "%1" && assoc .ext=' & $tmp_type, '', @SW_HIDE)
Link to comment
Share on other sites

Thx for your quick response.

I've tried "%1" "%*" and same problem (I get one instance for every file).

I managed to set up the SendTo and it's working ... I will probably need both methods implemented as I would like to have the custom icons and double-click Open that comes with file association.

As it can be done without registry, it would be nice to make file association work with multiple files though.

RunWait(@ComSpec & ' /c ftype ' & $tmp_type & '=' & @ScriptFullPath &  ' "%1" && assoc .ext=' & $tmp_type, '', @SW_HIDE)
I am having a problem even getting my script to associate with one selected file. How do I get the selected files location? So in the file types, where you specify your location of the executable and usually put a %1, how do I get the location of that file?

*Big time newbie here...*

- Edit -

I should qualify my question a bit. I am looking for the location of the file that was double clicked on in the windows explorer (or right clicked and opened). I know that you can use %1 for this on the command line. But my program does a bunch of things (like open another program) between executing and actually trying to open the file. So is there a way to grab the location of the file and store it until I need it?

Edited by Ben_Jones
Link to comment
Share on other sites

I should qualify my question a bit. I am looking for the location of the file that was double clicked on in the windows explorer (or right clicked and opened). I know that you can use %1 for this on the command line. But my program does a bunch of things (like open another program) between executing and actually trying to open the file. So is there a way to grab the location of the file and store it until I need it?

Take a look in Help under Running Scripts and you can start from there ... Keep in mind that %1 in Explorer means that the file name will be passed to your application as a parameter so, it's up to you to handle it.

Command Line Parameters

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0]is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...