Author Topic: Run MC with parameters to select file in specified folder  (Read 19 times)

Pawel

  • Junior Member
  • **
  • Posts: 40
    • View Profile
I want to run Multi Commander via external application.
This application runs MC and pases 2 parameters. A directory path and file name.
I want to focus on RIGHT panel (for example) and select this file in this directory.
How to do this?

I see Multi Commander support -Autorun parameter that allows to run a script.
Here is my UDC script:

I need to run Multi Commander with specified

##########################################
#Name:SelectMyFile
#Type:function
#ID:3dc58130a89d422c841855e79ab4c6bd
#Desc:File Selection
#Options:Confirm
##########################################

MC.Explorer.Goto PANEL=RIGHT PATH="${param:0}" ItemFocus="${param:1}"



Multi Commander is running with this code (Delphi):
           
MCParams := '-AutoRun="SelectMyFile ' + '""' + DIRECTORY_PATH + '"" ' + '""' + FILE_NAME_WITH_EXT + '"""';
ShellExecute(0, 'open', PChar(PATH_TO_MULTI_COMMANDER), PChar(MCParams), PChar(EmptyStr), SW_SHOWNORMAL);

It should work, but it is not!
What do I do wrong?

-Pawel

total_annihilation00

  • Power Member
  • ****
  • Posts: 197
  • Tech Savant\ Envisioneering
    • View Profile
Will this work ? While I'am not an expert in passing parameters, I had a similar issue when writing a Goto link Target script (no "Sleep()" delay so it didn't execute properly) Try this MultiScript in User-Defined command (should fix your rapid firing issue):
Multicommander MultiScript:
Code: [Select]
    @var $targetPath = ${arg:0};
    @var $targetFile = ${arg:1};
    MC.Explorer.Goto PANEL=RIGHT PATH="{$targetPath}"
    Sleep(1200);
    MC.Explorer.SetItemFocus PANEL=RIGHT ITEM="{$targetFile}"

Also, according to Grok 4.3 AI, it says your current Delphi code quoting is messy and likely breaking the parameter parsing. Use this cleaner version:
Delphi code:
Code: [Select]
MCParams := Format('-AutoRun="SelectMyFile ""%s"" ""%s"""',
                   [DIRECTORY_PATH, FILE_NAME_WITH_EXT]);

ShellExecute(0, 'open', PChar(PATH_TO_MULTI_COMMANDER),
             PChar(MCParams), nil, SW_SHOWNORMAL);

Let me know if it works or might need further tweaking (you get the gist), but I had a prob /w a Goto Link Target script, it wasn't focusing on the Set Item because it was firing too rapidly, adding a sleep and the correct syntax fixed it !
P.S: The MultiCommander MultiScript code I provided is sound, not sure about the Delphi fix though...
« Last Edit: Today at 07:54:48 by total_annihilation00 »
~The World's Deceit Has Raped My Soul, We Melt The Plastic People Down Then We Melt Their Plastic Town~