<pfaitem> items are passed one-by-one?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

<pfaitem> items are passed one-by-one?

Post by binocular222 »

I suspect this because when I pass a large number of video files to Media Player Classic Home-Cinema, there's significant lag, mis-order and duplication of items in mpc-hc playlist.
However, when use UDC Openwith (::#3), it seems all files are passed to mpc-hc at once and everthing goes smoothly, playlist ini mpc-hc is correct, no more lag.

1) Is that true?
2) Is there anyway to pass all <pfaitem> at once to target application?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

admin
Site Admin
Posts: 66303
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

Strange, cannot confirm. Both operations do NOT enforce multiple instances (UDC OpenWith can be configured to do so; PFA will never do).

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

<pfaitem> IS passed one by one when multiple files are selected. In fact the PFA association is executed once for each selected file. And each time <pfaitem> is the item currently being processed.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: <pfaitem> items are passed one-by-one?

Post by TheQwerty »

PFA/File>Open Selected Item(s) opens each item individually...

But POM/File>Open With... will open the selection in a single instance based on the current item, or first in selection - in which case <pfaitem> is only that item.

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

No, it's not about multiple instance. In both way, there's only 1 instance of mpc-hc. But the order of files appear in mpc-hc playlist is wild (randomized order, sometime duplicate). With UDC, the playlist is always the same as in XY's List.

Actually, I do not pass <pfaitem> parameter. My PFA is plain simple:
{:Media}>?:\Media Player Classic HomeCinema\x%osbitness%\mpc-hc.exe

My UDC:
E:\Media Player Classic HomeCinema\x%osbitness%\mpc-hc.exe

Then, how to pass ALL items at once?
Last edited by binocular222 on 16 Mar 2015 16:59, edited 2 times in total.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: <pfaitem> items are passed one-by-one?

Post by TheQwerty »

How do you have the PFA and UDC defined?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

MPC-HC is probably set up to open only one instance, like XYplorer's [ ] Allow Multiple instances.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

@Sammy: Yes, MPC-HC is set up to open only one instance
Another test: This PFA map to above mentioned UDC but the result is still a chaos

Code: Select all

{:Media}>::#1405
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

admin
Site Admin
Posts: 66303
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

OK, I somehow managed to overlook "<pfaitem>" in the OP and my answer only applies to File / Open With... (aka PFA). Here XYplorer definitely tells Windows to open all files in a single instance. However, it depends on the application whether this will actually happen.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: <pfaitem> items are passed one-by-one?

Post by TheQwerty »

With that PFA & UDC...

Open With... / POM / UDC (single instance) - XY opens a single instance of MPC with the list of selected items as arguments.
Open Selected Item(s) / UDC (multiple instances) - XY opens an instance of MPC for each selected item, the order in which MPC receives them is unpredictable and a bit of a race condition.

In both cases XY orders the selected items by starting at the focused item (even if it is not selected), goes down/right to the next item, and wraps around the list until all selected items are covered. I believe this is also the order used for the <items> and <selitems> variables.

(At least in my experience - correct me if wrong, Don.)

admin
Site Admin
Posts: 66303
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

That's correct. I copied this ordering from Explorer.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

I think PFA can benefit from a mechanism where the PFA (script) is called only once, by some kind of notation like the existing |-prefix to disable auto-execute.
binocular222 wrote:Then, how to pass ALL items at once?
Set a perm $counter for all matching pfa entries. then first run the program for all items at once, and start counting down the counter. As long as the counter exists the program won't run again. Delete the counter upon reaching the last matching item (when $counter==1) [ed. ~typo]

Code: Select all

{:Media}>::if !isset($count) { $allsels = <get selecteditemspathnames |>; $matches = formatlist($allsels, 'fns', '|', <get genericfiletype "{:Media}" "|">); perm $count = gettoken($matches,'count','|'); text $matches; run """C:\Program Files (x86)\MPC-HC\MPC-HC.exe"" ""$matches""";} else { $count--;} if ($count == 1){unset $count;}
I don't know the cmd arg syntax for mpc-hc. Format $matches as you need.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

I think a simple solution would be ignoring the feeding-items mechanism once user use ::
example:

Code: Select all

{:Media}>::$cmd = openwith "E:\Media Player Classic HomeCinema\x%osbitness%\mpc-hc.exe"; load "$cmd",,"s"
This should run the script as if a normal script would run
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

That will feed ALL selected files regardless of PFA match X number of items matching PFA to target app ! :shock:
Not recommendable if target app doesn't handle duplicate inputs well, or doesn't have instance management
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

I simplified the PFA example to stress my point: PFA passes items one-by-one even to :: script
That should be changed.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply