Multi Commander > Script

Select / deselect switch fault?

<< < (2/5) > >>

Mathias (Author):

--- Quote from: Ulfhednar on June 03, 2014, 16:20:13 ---Thanks Mathias.

Unfortunately I am most concerned about the deselection process.
MC leaves the hi-light/selection on zip#1.
I have discovered that if the .. at the top of the folder is hi-lited after each operation the script will run as I intended.  (I need to manually confirm overwrite etc during the process of course).

Can I make the selection move to the .. after a process?

if I have -

--- Code: ---..
xyz.zip
--- End code ---
-> extract *.*

I then get -

--- Code: ---..
1.jpg
2.txt
3.exe
xyz.zip

--- End code ---

& xyz.zip is still selected after the unpack

So with

--- Code: ---MC.Explorer.Select FILTER="*.zip"
MC.Filesystem.Unpack TARGET=${sourcepath} FILTER="*.*"
MC.Explorer.Deselect FILTER="*.*"
MC.Explorer.Select FILTER="*.txt"
// ...This would then be followed by a rename function.

--- End code ---

Sometimes only .zip is renamed or both txt & zip are renamed depending on how the selection bar behaves.  ??? 
Pic 3 was only achieved by selecting .. first, 1 & 2 are before & after the above script was run with no file selected.

If I do this process in steps & select the .. between the steps it will function correctly.  So I'd like to force deselect or selection of .. with hi-lite bar in active pane between each operation. 
Is that possible?

--- End quote ---


The Custom Commands are not really made to be run after each other.. they are used for simple action.
And calling them from a MultiScript is a "workaround" to be able to send dynamic parameters to it.
CustomCommands simulates that the user did the action from the UI. most of the time.. but sometimes not.
However many action in MC are done in the background or async and CustomCommand have no idea of that and will not wait.
So if you run multiple custom commands they can be called out of order. And since customcommand are sent via the UI layer (mostly) other change
that normally happens when the user do the action them self are also done. like it might change focus or selection and other stuff,
Unpack for example will unselect (v4.3,  did not before. but copy did) all and set focus item back to some item.
Since Custom Command goes via UI layer,  UI settings you have might also affect what is happening.

MultiScript commands are bypassing the UI layer. and act on core function directly as if there was no UI at all.

Mathias (Author):
It think it would work better if you use MultiScript to find all files matching *.zip and then call unpack with all the zip files to unpack


--- Code: ---@var $arrFiles = FindFiles("R:\\zipfiles\\*.zip");
@var $count = arrayCount($arrFiles);
@var $zipFiles = "";
@var $zip;
@var $n;
// Create ; separated list with all zip files to unpack
for( $n = 0; $n < $count ; $n++ )
{
 $zip = $arrFiles[ $n ];
 $zipFiles += $zip;
 $zipFiles += ";";
}

MC.Filesystem.Unpack FILE="{$zipFiles}" TARGET="r:\unp"
--- End code ---


Ulfhednar:
Sorry for giving you a lot of work explaining this!   

I can see now why sometimes my script could work & others not.  I think it did it perfectly once then went back to variable & jumbled....
But I was able to use MC.RunCmd ID="ExplorerPanel.41075" to get to the ..   :)  :)

I wonder if it would be possible to force custom commands to run in a sequence? 
Perhaps you could see a simple way to implement what is perhaps a kind of 'macro' function for Custom Commands.  (Maybe they are too exclusive in terms of environment to do this?) 
This makes me wonder about a plugin that would batch run Custom Commands + variables, in the GUI frontend.
e.g. Effectively if you had 3 virtual buttons with MC.Commands assigned, the 'macro' would run them in an assigned sequence.
This is a bit ambitious for me to try right now tho!!  ;)

I do not know how much work that entails or whether it is worth considering given your full road-map....

Thank you very much for the script I can use that to start over & work towards a real result! ;)
I will post back what I end up with.

Mathias (Author):

--- Quote from: Ulfhednar on June 04, 2014, 12:44:53 ---I wonder if it would be possible to force custom commands to run in a sequence? 

--- End quote ---
You can.. But the order is not guaranteed. and not recommended, All depend on the command used.
If you need to do more then 1 thing.  then use MultiScript as much as possible.
CustomCommand are only there so minor things can be done simply. if you need complex tasks.  MultiScript should be used.


--- Quote from: Ulfhednar on June 04, 2014, 12:44:53 ---Perhaps you could see a simple way to implement what is perhaps a kind of 'macro' function for Custom Commands.  (Maybe they are too exclusive in terms of environment to do this?) 
This makes me wonder about a plugin that would batch run Custom Commands + variables, in the GUI frontend.
e.g. Effectively if you had 3 virtual buttons with MC.Commands assigned, the 'macro' would run them in an assigned sequence.
This is a bit ambitious for me to try right now tho!!  ;)

--- End quote ---
No Do not think it is possible. many custom commands are async.. You Fire them off and then continue without waiting.

But if you find a user case of something you want to automate/script. Then we can see if some script function might be needed.
to be able to do that.  Also plugin have full access to everything inside MC. and can do even more. But that require C++ knowledge :)

Ulfhednar:
My plans have hit a snag...

Your script works perfectly (obviously!), but I don't seem to be able to give it the source path.
The GetSelectedPaths(); & GetSourcePath(); commands don't seem to be able to be used with my existing syntax.
I know the path can be seen as an array so I tried various versions of

--- Code: ---@var $arr = GetSourceSelectedPaths();
@var $arrFiles = FindFiles("{$arr}\*.zip");
--- End code ---
& also as a string

--- Code: ---@var $path = GetSourcePath();
@var $arrFiles = FindFiles("{$path}\*.zip");
--- End code ---

After a lot of attempts & variations I still cannot see how to pass the path to the FindFiles command
I am missing variables &/or syntax, & just cannot see how to implement something like ${source}

I feel I should be able to figure this out but I am struggling  :-[  (& I am reading the online docs)

I appreciate you taking time to explain how the command system works.
I would like to gain some more coding knowledge.  C++ has interested me in the past, & if I get time for this I will try & get into it.  Would be nice to make a contribution to MC that is useful!!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version