[XYScript] ChildLauncher: Launch Relative Programs

Discuss and share scripts and script files...
WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

[XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

ChildLauncher
ChildLauncher
ChildLauncher
imPMPqp.png (75.12 KiB) Viewed 3830 times
Introduction
If you're like me, you might have your XYplorer folder alongside other portable programs. A folder structure that looks something like this...

Code: Select all

PortableApps\
    FireFoxPortable\
        FireFoxPortable.exe
    GitBashPortable\
        GitBashPortable.exe
    XYplorer\
        XYplorer.exe
ChildLauncher will collect all the executables in these sibling folders and display them in a menu for you to launch. If you're familiar with the PortableApps Launcher, this is very similar. The goal was to replicate that launcher and some of its features to be used seamlessly in XY.


Features
  • Display additional programs: Not all your programs will be in a sibling folder, some may be in different locations, such as the Program Files folder. In these cases, you can specify the location of that program and it will appear in the ChildLauncher menu, right alongside the sibling programs. (As seen with the Affinity programs in the screenshot above)
  • OpenWithMode: Instead of just starting the selected program, use it to open the currently selected file(s). You can start OpenWithMode from either a toolbar button or by running a script command, which can be assigned to a hotkey for quick access. The script command can even be used in the CFA menu, where it works great as a catch-all for unknown file-types. See the v2.0 [05/18/2022] update for instructions on how to initiate OpenWithMode.
  • Hide executables: Not all executables are meant to be started directly. Hide programs such as XYCopy.exe from being displayed.
  • Change display names: Some executables aren't named how we would like to see them. Easily define name changes, such as displaying Affinity Photo instead of the executable's actual name, Photo. (As seen in the screenshot above)
  • Custom program icons: Sometimes the icon of a program isn't the one we recognize/prefer. If you'd like to change it, you can easily specify a different icon to be displayed for that particular program.
  • GUI Configuration: Prior to v3.0, configuration was done by editing a .ini in a text-editor. With current versions, interface-based configuration is possible. Add programs, change display names, set custom icons, and hide programs, all through simple prompts. The configuration options are found at the bottom of the ChildLauncher list. Other settings can still be found in the top section of the configuration .ini file.
  • Remove Portable from the display name: Programs downloaded from PortableApps have the word Portable appended to their filename, which gets really redundant... Gone.
  • Large Icons: The icons in the screenshot above are 32x32. If those are too big for your liking, disable large icons to use the smaller 16x16 instead.
  • Set window width/height: If the default ChildLauncher window is too big/small for your setup, you can specify in pixels what size the window should be.


Instructions
ChildLauncher is designed for users who keep their XYplorer folder alongside other programs, with a folder structure like the example above. If you've installed XY to your Program Files folder, this script won't work too well for you because of the inconstancy between folder hierarchies.

If you're using ChildLauncher for the first time, download and extract the script from the link below. Copy the ChildLauncher folder into your <xyscripts> directory and load the script using your preferred method.

ChildLauncher is configured using a .ini file, which I've included in the download. You can either configure it using the GUI options at the bottom of the ChildLauncher list, or manually using a text editor. Deleting entries can only be done manually.

If you use the PortableApps Launcher, you can copy-paste the same key:value pairs that are saved in PortableAppsMenu.ini into ChildLauncher's .ini. Useful for if you've already hidden/renamed files in the PortableApps Launcher.

This is the first script I write that's not part of a popupnested() menu. A lot of the functionality I used is new to me and I wrote this in only a few hours. It may not be the cleanest approach, but it works! Any feedback is appreciated.


Download
If upgrading to v3.0+, prior configuration files are not supported. Start fresh.
ChildLauncher (v3.0).7z
v3.0
(110.44 KiB) Downloaded 152 times

Changelog

Code: Select all

v3.0 [05/21/2022]
    ! Previous .ini configuration files are no longer compatible with v3.0+, read this thread for more info: https://www.xyplorer.com/xyfc/viewtopic.php?f=2&t=24681
    
    + Configure ChildLauncher through the GUI: At the bottom of the ChildLauncher window, you'll find 4 new options; Add Application, Rename Applications, Custom Icons, and Hide Applications.
    	As their name suggests, they'll allow you to configure ChildLauncher through the interface. For most people, this will be a lot easier/quicker than editing the .ini in a text-editor.
    	
    	! Removing Applications/Renames/Icons through the GUI is not supported nor planned. Delete the lines from the .ini using your text-editor.
    	Tip: To maintain portability, put your custom icons in the <xyicons> folder and then replace the path with <xyicons> when confirming the changes.
    	    
    + AppsIcons: You can now define custom program icons to be displayed in the ChildLauncher window in the [AppsIcons] section of the configuration file. Like the Rename and Hide options, custom icons only apply to sibling programs that are scanned for by ChildLauncher. For manually added programs,  there was already an option to add them when configuring the .ini.

-----------------------------------------------------------------------------------------------------------------------------------------------------

v2.0 [05/18/2022]
    + OpenWithMode: This new mode will generate the same list of programs as normal, except it will append <selitems> to whatever application you choose. 
    This means that instead of just opening that program, the currently selected files will be opened into that program, hence the name "OpenWithMode".
    You also have the option to browse your filesystem for an application, should it not be in your list. 
    
    There are 2 methods to start ChildLauncher in OpenWithMode:
    
        Method 1) Toolbar Button: Create a toolbar button to load ChildLauncher. Highlight the desired items in your list and then "Left-Click + Shift" on the toolbar button. 
        ChildLauncher will start in OpenWithMode.
        
        Method 2) Run Script: This is useful if you would like to assign a keyboard shortcut to start ChildLauncher in OpenWithMode, or if you want to use OpenWithMode in the CFA menu for unknown file-types ("ChildLauncher"*>{OpenWithModeCommand}). 
        Run the command below to start ChildLauncher in OpenWithMode
        ::perm $P_CHILDLAUNCHER_OPENWITHMODE = "true"; load "<xyscripts>\ChildLauncher\ChildLauncher.xys";
    
    + OpenWithFiletypes: New option to filter what filetypes will be displayed when selecting the "Browse for Application..." of OpenWithMode.
    + LargeIcons: New option to enable large icons (32x32).
    + Window Width/Height: New option to specify in pixels the width/height of the ChildLauncher window.

-----------------------------------------------------------------------------------------------------------------------------------------------------
v1.5 [05/17/2022]
    + Check to make sure each program defined in [AppsAdditional] actually exists. If it doesn't, don't display it in the results. This is to prevent broken links when switching between computers.
    ? Keys in .ini are not case-sensitive: During my initial testing, I found that retrieving key:value pairs from a .ini was case-sensitive. It must have been bad code because now they're working fine regardless of the case...  ┐(゚ ~゚ )┌
    * Syntax cleaning: Code was inconsistent, hard to read, and lacked commenting. Fixed.
-----------------------------------------------------------------------------------------------------------------------------------------------------
v1.0 [05/16/2022]
    + Initial release. Quick and dirty but it works... I stayed up way past my bed-time for this...

Previous Versions
ChildLauncher(v2.0).7z
v2.0
(55.34 KiB) Downloaded 120 times
ChildLauncher.7z
v1.5
(27.07 KiB) Downloaded 112 times
ChildLauncher.7z
v1.0
(26.26 KiB) Downloaded 119 times
Last edited by WirlyWirly on 22 May 2022 01:52, edited 40 times in total.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by highend »

A few cosmetic notes

- "<xyparent>" = Unnecessary quoting. You may need this for run / lax / runret calls, but not in this context
- E.g.: "$key" as well

- Sometimes you use (lower) camel-case for vars, sometimes underscores. Choose one, stay with it. Lower camel-case preferred

- And sometimes even a first letter uppercase ones: $Count

- Hard to read / interpret (for script newbies): "$exe:::", preferred: $exe . ":::"

- Even more so: "app$Count" => "app" . $Count"

- While doing that for a path can still make sense (personal preference...): "$parent\$filename"

- Be careful with things like: if ($RemovePortable == "true") {
If a user accidentally uses "True" you're f.... Better use LikeI in such cases (or a regexmatches())

- Use better code formatting^^

Code: Select all

        $filename = regexreplace($item, "\|(.+)", "$1");
        $parent   = getpathcomponent($filename, "parent");
        $filename = getpathcomponent($filename, "file");
        $key      = recase("$parent\$filename", "l");
One of my scripts helped you out? Please donate via Paypal

yogi
Posts: 100
Joined: 18 Feb 2010 09:05

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by yogi »

thanks wirly ! i like portable application , but i am with symeny app ;
i try now your script !

a question, if my applications are not in "xyparent" but in another folder of my key? what should i change to point on it??

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

@highend
Thanks for the feedback, when I first started the code I was using snakecase for my variables. As the syntax became clearer, I realized it was very similar to JavaScript (even the .js syntax highlighting is accurate), so I switched over to camelcase. By the time I finished the code it was past my bed-time, so I just left it as-is. I'll be going in later and standardizing it to camelCase as-well as picking more descriptive variable names.

I agree with you on the string formatting. I had python's f-strings in mind, but since I'm relating the syntax to JavaScript I should use the dot format. I'll fix em up and make it easier to read.

As for formatting, good call. I don't usually do it but I've been meaning to start. Gotta figure out how to enable it in my editor.

@yogi
You can use any absolute path in the [AppsAdditional] section of the .ini file. It also works for programs that aren't in your C:\ drive. Just make sure to use a lowercase absolute path.

Allowing additional search locations besides <xyparent> sounds useful. I'll see what I could do about integrating it into the next update.

yogi
Posts: 100
Joined: 18 Feb 2010 09:05

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by yogi »

Let me understand. You have to edit the ini file? I thought you just had to change the parent folder in the xys. By the way this way it works if it is in the xyplorer folder.

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

yogi wrote: 16 May 2022 20:31 Let me understand. You have to edit the ini file? I thought you just had to change the parent folder in the xys. By the way this way it works if it is in the xyplorer folder.
Moving your XYplorer folder so that it's in a folder structure like in the example above is the easiest approach. It has to be in the same parent folder as your other portable programs.

Everything in the .ini file is optional, you don't have to change anything if you don't want to. Some of the features are useful though, so if you want to use them you will need to edit the .ini.

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

Code: Select all

v1.5 [05/17/2022]
    + Check to make sure each program defined in [AppsAdditional] actually exists. If it doesn't, don't display it in the results. This is to prevent broken links when switching between computers.
    ? Keys in .ini are not case-sensitive: During my initial testing, I found that retrieving key:value pairs from a .ini was case-sensitive. It must have been bad code because now they're working fine regardless of the case...  ┐(゚ ~゚ )┌
    * Syntax cleaning: Code was inconsistent, hard to read, and lacked commenting. Fixed.

yogi
Posts: 100
Joined: 18 Feb 2010 09:05

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by yogi »

thanks !!

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

Code: Select all

v2.0 [05/18/2022]
    + OpenWithMode: This new mode will generate the same list of programs as normal, except it will append <selitems> to whatever application you choose. 
    This means that instead of just opening that program, the currently selected files will be opened into that program, hence the name "OpenWithMode".
    You also have the option to browse your filesystem for an application, should it not be in your list. 
    
    There are 2 methods to start ChildLauncher in OpenWithMode:
    
        Method 1) Toolbar Button: Create a toolbar button to load ChildLauncher. Highlight the desired items in your list and then "Left-Click + Shift" on the toolbar button. 
        ChildLauncher will start in OpenWithMode.
        
        Method 2) Run Script: This is useful if you would like to assign a keyboard shortcut to start ChildLauncher in OpenWithMode, or if you want to use OpenWithMode in the CFA menu for unknown file-types ("ChildLauncher"*>{OpenWithModeCommand}). 
        Run the command below to start ChildLauncher in OpenWithMode
        ::perm $P_CHILDLAUNCHER_OPENWITHMODE = "true"; load "<xyscripts>\ChildLauncher\ChildLauncher.xys";
    
    + OpenWithFiletypes: New option to filter what filetypes will be displayed when selecting the "Browse for Application..." of OpenWithMode.
    + LargeIcons: New option to enable large icons (32x32).
    + Window Width/Height: New option to specify in pixels the width/height of the ChildLauncher window.

OpenWithMode
OpenWithMode
2022-05-18_18-02-43.png (75.07 KiB) Viewed 3975 times
Last edited by WirlyWirly on 20 May 2022 06:36, edited 1 time in total.

noembryo
Posts: 100
Joined: 13 Apr 2022 21:40

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by noembryo »

Thank you for sharing this very handy script.. :appl:
Something that I would really like, is a way to hide/rename apps, from within the list.
I suppose you're not have access to the right click menu, but you could use a click with a modifier or something.

I have more than ~250 entries as it is, so, I want to avoid copy/pasting addresses to sanitize the list.
It is still very useful, I just have to be a little more careful in what I press.. :P
Check my free programs here..

noembryo
Posts: 100
Joined: 13 Apr 2022 21:40

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by noembryo »

... and since I started the wishes, another one would be to have a Tooltip with the file's path, when hovering the mouse over an entry.
Sometimes, I have different versions of programs that I can't distinguish them, like these:
ChildLauncher1.png
ChildLauncher1.png (4.54 KiB) Viewed 3911 times
Check my free programs here..

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

I was thinking the same thing, copy-pasting paths gets tiresome and is prone to error.

For show/hide, I think what I'm going to do is add another modifier to the toolbar button that will bring up the same list but with checkboxes. You'll be able to toggle show/hide status through these checkboxes.

For renaming, it'll be more tricky since I remove the word Portable from the filename. I'm still thinking over my options, either through checkboxes again or displaying an input field when the user selects a program.

I also plan to make it easier to add additional programs. I'll bring up a window for the user to find a .exe file, then they input a display name, and optionally they can select an icon. Simple enough.

I'll see what I can do about a tooltip, I ran into the same issue myself with a few programs.

This is my first real xys-scripting attempt, so this whole thing is a learning-process and my little playground of sorts... Anything could break at any time :D

noembryo
Posts: 100
Joined: 13 Apr 2022 21:40

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by noembryo »

WirlyWirly wrote: 19 May 2022 18:12 I was thinking the same thing, copy-pasting paths gets tiresome and is prone to error.

For show/hide, I think what I'm going to do is add another modifier to the toolbar button that will bring up the same list but with checkboxes. You'll be able to toggle show/hide status through these checkboxes.
Excellent!
For renaming, it'll be more tricky since I remove the word Portable from the filename. I'm still thinking over my options, either through checkboxes again or displaying an input field when the user selects a program.
What I was referring to was the display name, not the actual filename.
It's nice that you remove the "Portable" part of it.
You can give the users the original name (with the portable), and let them decide what they want to keep.. :P
I also plan to make it easier to add additional programs. I'll bring up a window for the user to find a .exe file, then they input a display name, and optionally they can select an icon. Simple enough.
A welcome addition too.. :tup:
I'll see what I can do about a tooltip, I ran into the same issue myself with a few programs.

This is my first real xys-scripting attempt, so this whole thing is a learning-process and my little playground of sorts... Anything could break at any time :D
Enjoy yourself, and thanks for sharing.. :appl:
Check my free programs here..

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by WirlyWirly »

With v3.0, I've added all the core-functionality I was hoping for. I'll be slowing down on any new features, I'm more than happy with the current state :beer:

Code: Select all

v3.0 [05/21/2022]
    ! Previous .ini configuration files are no longer compatible with v3.0+, read this thread for more info: https://www.xyplorer.com/xyfc/viewtopic.php?f=2&t=24681
    
    + Configure ChildLauncher through the GUI: At the bottom of the ChildLauncher window, you'll find 4 new options; Add Application, Rename Applications, Custom Icons, and Hide Applications.
    	As their name suggests, they'll allow you to configure ChildLauncher through the interface. For most people, this will be a lot easier/quicker than editing the .ini in a text-editor.
    	
    	! Removing Applications/Renames/Icons through the GUI is not supported nor planned. Delete the lines from the .ini using your text-editor.
    	Tip: To maintain portability, put your custom icons in the <xyicons> folder and then replace the path with <xyicons> when confirming the changes.
    	    
    + AppsIcons: You can now define custom program icons to be displayed in the ChildLauncher window in the [AppsIcons] section of the configuration file. Like the Rename and Hide options, custom icons only apply to sibling programs that are scanned for by ChildLauncher. For manually added programs,  there was already an option to add them when configuring the .ini.
2022-05-21_15-19-49.png
2022-05-21_15-19-49.png (71.33 KiB) Viewed 3827 times

noembryo
Posts: 100
Joined: 13 Apr 2022 21:40

Re: [XYScript] ChildLauncher: Launch Relative Programs

Post by noembryo »

Haven't checked a lot because its late here, but one thing I noticed is this:
Although my first entries have two 7-zip apps and one ABBYYFinerReader app
0.png
0.png (5.85 KiB) Viewed 3810 times
when I try to hide the first 7-zip entry, I get this..
1.png
1.png (7.73 KiB) Viewed 3810 times
..which has one 7-zip app and three ABBYYFineReader apps..

Anyway, thanks for the update! :party:
I will check it more thorough tomorrow.. :)
Check my free programs here..

Post Reply