USer-Defined Command Subfolders

Features wanted...
Post Reply
Quaraxkad
Posts: 181
Joined: 20 Apr 2014 18:01

USer-Defined Command Subfolders

Post by Quaraxkad »

I have a growing list of USer-Defined Commands, spefically under Load Script File Category. Would it be possible to add a feature where these commands can be organized into subfolders, instead of one long menu?

eil
Posts: 1821
Joined: 13 Jan 2011 19:44

Re: USer-Defined Command Subfolders

Post by eil »

If you use "load script" from that menu, why not simply make a single Main script entry, which would be actually a nested popupmenu(organized in what-ever subfolders structure you want) for calling those scripts. You may assign a shortkey for calling that menu in any moment or say addd it to Custom Button.
Win 7 SP1 x64 100% 1366x768|1900x1080

Quaraxkad
Posts: 181
Joined: 20 Apr 2014 18:01

Re: USer-Defined Command Subfolders

Post by Quaraxkad »

I'm not sure what you mean... Can you provide an example?

eil
Posts: 1821
Joined: 13 Jan 2011 19:44

Re: USer-Defined Command Subfolders

Post by eil »

If your problem is "too long list of UDC = not comfortable to launch those scripts"(as i understood it), then check this example from the Help file - nested sub-menus:

Code: Select all

     $menu = <<<MENU
               Top;;:paper;1
                 Sub;;;4
                 Sub
                   Sub2;;*.ini
                   Sub2
                   Sub2;;;2
               Top;;<xy>
             MENU;
       text popupnested($menu);
Now add "load your_script_names" as entries and you have "sub-folders" with scripts you use in UDC.
Win 7 SP1 x64 100% 1366x768|1900x1080

Quaraxkad
Posts: 181
Joined: 20 Apr 2014 18:01

Re: USer-Defined Command Subfolders

Post by Quaraxkad »

So essentially a script that opens a nestable menu of other scripts? I suppose that could work.

I'm sure there are a lot of ways to achieve my goal here, so to elaborate on my set up: I already have a list of scripts under UDC, and a toolbar button that opens the User>Load Script File submenu. One of those script is Open With. Yes, I'm aware there's a built in Open With function under UDC, but my script works differently. Running the script asks me to select an executable or batch file and aks if I want the window to be visible (so I can launch hidden console windows). How it differs from the built-in function is that my script processes each selected file one at a time, where the built-in function either sends all the selected items to the same process or each item to a new process *all at the same time*.

Code: Select all

 $proggy = inputfile("c:\programs\", "exe|bat");
 $aprompt = confirm("Show Program Window?","",1,4);
 foreach($file, <get selecteditemspathnames |>) {
  $parentdir = getpathcomponent($file, "path");
  run """$proggy"" ""$file""", $parentdir, 1, $aprompt;
 }
The reason for the submenu suggestion here was so that instead of selecting an executable using the inputfile() Open dialog, I would have separate menu items for my most-used executables so that they don't clutter up the top level script menu, and streamline the use of the script so that it doesn't require manually browsing to the required exe directory. Using your suggestion, I would probably make a second toolbar button that runs a script to display a *different* menu of scripts.

That brings me to a different question/suggestion... Can I pass parameters/arguments to a script? For example if I passed an exe path to the above Open_With.xys script, I would have it use that path instead of prompting with inputfile(). Then I could keep just the one script instead of a different script for every exe/bat I want shortcuts for.

eil
Posts: 1821
Joined: 13 Jan 2011 19:44

Re: USer-Defined Command Subfolders

Post by eil »

Considering your setup, i hope smbd more sophisticated can elaborate some possible improvement solutions.
As for my idea - indeed, it would be a scripted menu with whatever sub-structure you wish, that simply runs other scripts. Passing parameters/arguments can be done via permanent variables, sharing values from one script to another. Check those in Help file. They can be either "temporary" stored in memory for the whole XY session(unlike usual variables that are erased after script end) or saved to XY data and be auto-loaded on next run.
Win 7 SP1 x64 100% 1366x768|1900x1080

Quaraxkad
Posts: 181
Joined: 20 Apr 2014 18:01

Re: USer-Defined Command Subfolders

Post by Quaraxkad »

I haven't figured out any way to accomplish this that isn't messy and convoluted. Any chance subfolder supoport could be added to User-Defined Commands?

WirlyWirly
Posts: 274
Joined: 21 Oct 2020 23:33
Location: Win 10 @ 100% (3440x1440)

Re: USer-Defined Command Subfolders

Post by WirlyWirly »

I don't completely understand your setup, but if you're wondering about passing parameters to a script as you load it, you can do that by first assigning the parameters as a global variable, loading the script, and then from within the script reading that global variable.

I do this myself to start my ChildLauncher script in OpenWith mode, so that the application I pick will open the selected item(s) instead of just starting the program.

Here is how that looks like as a CustomFileAssociation, where I keep it as the last line so it works like a "Catch-all" for unknown filetypes...

Code: Select all

"ChildLauncher"; *>::perm $P_CHILDLAUNCHER_OPENWITHMODE = "true"; load "<xyscripts>\ChildLauncher\ChildLauncher.xys";
Then, here are the lines from within the ChildLauncher.xys script that I use to check for that "parameter". Notice that I unset the variable when I'm done with it, just so that the next time I run the script, it's not defaulting to OpenWith mode...

Code: Select all

...
    perm $P_CHILDLAUNCHER_OPENWITHMODE;
    if ($P_CHILDLAUNCHER_OPENWITHMODE LikeI "true") {
        $openWithMode = "true";
	}
    unset $P_CHILDLAUNCHER_OPENWITHMODE;
...

Post Reply