Page 1 of 2

starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:31
by zakhar
Hello, dear XYplorer Community!

I would like to know, if it is possible to start a script by clicking on a paperfolder item.
(something like Custom File Associations)

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:34
by highend
Single click directly on the item? No. Double-click, sure, use a CFA with a script...

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:39
by zakhar
highend wrote: ↑02 Nov 2021 14:34 Single click directly on the item? No. Double-click, sure, use a CFA with a script...
What I do not understand is what I should write there in CFA so that CFA understands, that the call comes from a paperfolder item.

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:42
by highend

Code: Select all

if (regexmatches(tab("get", "path"), "^paper:")) {
    // do something here?
}

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:46
by autocart
zakhar,
A paperfolder item, what is that for you?
An item inside a paperfolder, i.e. when you have the paperfolder open in the list view and you are then clicking on one of those items in that list view?

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 14:56
by zakhar
highend wrote: ↑02 Nov 2021 14:42

Code: Select all

if (regexmatches(tab("get", "path"), "^paper:")) {
    // do something here?
}
highend, this is already a script.
I mean the CFA must be given as "[file extension or "something mentioned in XYplorer's Help file under CFA"]>[action]".
Edit: And the paperfolders are not mentioned in "XYplorer's Help file under CFA".
autocart wrote: ↑02 Nov 2021 14:46 A paperfolder item, what is that for you?
XYplorer's Help file: "Paper Folders are simple text files that contain the full paths to items, one per line. XYplorer employs those files as virtual folders.".
autocart wrote: ↑02 Nov 2021 14:46 when you have the paperfolder open in the list view and you are then clicking on one of those items in that list view?
I would say not "when you have the paperfolder open" but "when you have the paperfolder loaded".

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:07
by zakhar
I have found something under CFA in XYplorer's Help file:
"Variables
XYplorer native variables and environment variables are supported in the pattern list. E.g., the following pattern will only match TXT files in the Paper Folder folder:
<xypaper>\*.txt>::echo <focitem>;".
I will try it now.

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:14
by highend
So you were not talking about paper folder items but the paper folder files themselves...

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:29
by autocart
zakhar wrote: ↑02 Nov 2021 14:56 I mean the CFA must be given as "[file extension or "something mentioned in XYplorer's Help file under CFA"]>[action]".
[action] can be a one-line script:
["something mentioned in XYplorer's Help file under CFA"]>::if (regexmatches(tab("get", "path"), "^paper:")) {// do if paper} else {//do if not paper}

EDIT:
To open a non-paper-folder-item with the default application:
["something mentioned in XYplorer's Help file under CFA"]>::if (regexmatches(tab("get", "path"), "^paper:")) {// do if paper item} else {open <pfaitem>, w;}

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:44
by zakhar
highend wrote: ↑02 Nov 2021 15:14 So you were not talking about paper folder items but the paper folder files themselves...
No! :)
PaperFolder Items in my posts are folders or files represented in the XYplorer's list after XYplorer has loaded the txt-file as paperfolder.

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:54
by zakhar

Code: Select all

<xypaper>\*.txt>::load "<xypath>\Data\Scripts\pf.xys";
does not work as I expect it to work:
After clicking on an item (a folder in the XYplorer's list in a loaded paperfolder)
the experimental script pf.xys (only

Code: Select all

echo "1";
) does not start.

Do not know what to do. :cry:

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:58
by highend
Of course not. CFA doesn't support folders, use a custom event action with a changing location event for these

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 15:58
by autocart
zakhar wrote: ↑02 Nov 2021 15:54

Code: Select all

<xypaper>\*.txt>::load "<xypath>\Data\Scripts\pf.xys";
does not work as I expect it to work:
After clicking on an item (a folder in the XYplorer's list in a loaded paperfolder)
the script pf.xys (only echo "1";) does not start.

Do not know what to do. :cry:
Of course. You quoted it yourself.
wrote:E.g., the following pattern will only match TXT files in the Paper Folder folder:
<xypaper>\*.txt>::echo <focitem>;".
Put <xypaper> in the address bar and hit Enter. Then you will understand. That's why highend got confused with what you want.

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 16:01
by autocart
zakhar wrote: ↑02 Nov 2021 15:54

Code: Select all

<xypaper>\*.txt>::load "<xypath>\Data\Scripts\pf.xys";
After clicking on [...] a folder
highend wrote: ↑02 Nov 2021 15:58 Of course not. CFA doesn't support folders, use a custom event action with a changing location event for these
Oh, but even if CFA did support folders, why do you, zakhar expect *.txt to be triggered when clicking a folder?

Re: starting a script by clicking on a PaperFolder item

Posted: 02 Nov 2021 16:04
by autocart
zakhar wrote: ↑02 Nov 2021 15:54 Do not know what to do. :cry:
Did you already try what highend and me wrote up above?
I don't think so. E.g. viewtopic.php?p=192451#p192451