Again thanks to TheQwerty for giving me a head start with this
The script below is what I came up with and fully satisfies my needs as that it doesn't override the default behavior of Enter / Double-Click
This can be bound to a shortcut and is intended to expand on the Open Focused Item shortcut Ctrl+Enter
It has the following features:
- reads PFA list from ini file
- so remember to save settings after making changes to your PFA list
- designed to support the following syntax: |"caption|path/to/icon" ext1;ext2>path/to/program
- for this script to use a PFA it is required to begin each PFA entry with a | (pipe) and it should be enabled (ticked) in the list.
- The caption is optional, the path/to/icon is optional, the path/to/executable doesn't need to be quoted
- Press SELECT ALL on the code block below
- Press Ctrl+C to copy it to clipboard
- In XYplorer go to User -> Manage Commands...
- Select the the Run Script Category on the left side
- Click the New button on the right side
- Enter Open Focused Item with PFA as Caption
- Click the Edit button right next to the Script: field
- Press Ctrl+V in the Edit Script window
- Click the OK button
- Click the Assign Keyboard Shortcut... button
- Press Ctrl+Enter (or whatever shortcut you want)
- Click the OK button of the Free Keyboard Shortcuts window
- Click the OK button of the Manage User-Defined Commands window
- Done
Code: Select all
"Open Focused Item with PFA"
// designed to support the basic ext format from PFAs: ext;ext>path/to/executable
// could possibly support more, or might break, if you could test it and report back that'd be great :)
$PFACount = getkey("Count", "FileAssoc");
// might improve performance when just reading file once instead of doing it for every single PFA
$PFAMatch = "";
while ($PFACount > 0) {
$PFA = getkey($PFACount, "FileAssoc");
// if the PFA is activated (has +) and not already overriding the default application (has |)
// the compare function returns 0 if the strings are equal
if (!compare(substr($PFA, 0, 2), "+|")) {
if(gettokenindex('"', gettoken($PFA, 1, ">", "t"), ">")) {
$PFAnoCaption = gettoken($PFA, 3, '"', t, 2);
}
else {
$PFAnoCaption = substr(gettoken($PFA, 1, ">", t, 2), 2);
}
// If the focused item's extension is in the list
$PFAexts = gettoken($PFAnoCaption, 1, ">", "t");
if (gettokenindex(<curext>, $PFAexts, ";")) {
$PFAMatch = $PFA;
break;
}
}
$PFACount--;
}
if ($PFAMatch) {
openwith gettoken($PFAnoCaption, 2, ">", "t"), "s", <curitem>;
}
else {
#162; // File | Open Focused Item
}
XYplorer Beta Club