Power Launcher [v1.5 alpha4]

Discuss and share scripts and script files...
FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Power Launcher [v1.5 alpha4]

Post by FluxTorpedoe » 19 Feb 2013 14:19

Hi'

=======================
Power Launcher v1.5alpha4 *Codename Bloater*
=======================

- Updated 2013-03-13 -
Main changes:

• [1.5a4] Easily associate scripts and subscripts (Labels) - In PowerLauncher-Definitions:
[pre]To open file or folder with XYS script, add name of script with ".xys" extension, e.g.
aud=AudioConvert.xys
To call specific label in XYS script, use CL, e.g.
vid=CL|VideoConvert.xys|_HighQuality[/pre]

Manage all your associations in one place, not only PowerLauncher LeftClick and RightClick, but also PortableFileAssociations DoubleClick (with a catchall from PFA > PL)
Define 2 possible associations for everything (PFA's 2C, PL's LC, PL's RC), so if one program (e.g. local MediaPlayer x64) is unavailable, the secondary is used (e.g. Portable MediaPlayer x86)
Use Keyboard Shortcuts to directly open your file with one of the 3(x2) PowerLauncher's associations


Foreword:
- Not (yet) for casual users who aren't into customization, sorry.
- Recommended to power users and users relying heavily on portability.


FEATURES:

:arrow: If you regularly need to open files with something else than the default application (on double-click), PowerLauncher (PL) is for you!
When edited and assigned to a Custom Toolbar Button (CTB), this script will:
- detect the type of the selected file (audio, video, pdf,...),
- detect the left click (LC) or Right Click (RC) on PowerLauncher button,
- launch a specific application or script to open this file (different depending on LeftClick or RightClick)
:arrow: Use it also if you want to manage your Portable File Associations in the same place, with secondary associations in case the primary isn't found
Note: "open with" mode or "command-line arguments" mode are supported.

WARNING - Prerequisites:

:!: This script MUST BE EDITED (at least to input the path of your applications) - it won't work as is.
=> You must know how to retrieve the path of your applications (and command-line if necessary).
:!: For the RightClick function to work, you must have the following tweak enabled (set to 1):
CTBNoRClickDefaultCommands=1
It enables "Direct RightClick" by removing the "Edit, Customize..." from RightClicks on CTB. They can still be accessed by CTRL+RightClick on CTB.

USAGE:

• Install PowerLauncher and edit its Definitions INI file (procedure below)
• Select one or several similar files of your choice (e.g. "myvideo.avi" and "yourvideo.avi") then LC or RC on your PL button to have PowerLauncher open it with your associated application (e.g. VLC)...

USAGE EXAMPLES:

Working example:
:arrow: Select one of your (meaningful) XYS scripts. LeftClick on PowerLauncher button, and see it running (without having to write "::load "MyOtherScriptsPath\blablabla"")
Other case scenarios:
• You want to show your videos at a party but aren't sure what player and codecs your friends have:
- On your flashdrive, put portable XYplorer and VLC (assigned to videos to the LC of PL)
=> now a LeftClick on PowerLauncher button will open all your videos through VLC.
• You like to have SumatraPDF as the default PDF viewer for its unmatched speed (I do!) but sometimes need more power:
- a regular DoubleClick can open your PDFs in SumatraPDF (assigned as the default PFA opener [Tools > Customize File Associations...])
- a PL-LC can open them in PDFXchange Viewer (assigned as PL-LC)
- a PL-RC can open them in Acrobat (assigned as PL-RC)
• You have to work on a friend/client computer and don't know if they have an archiver:
- a PL-LC can open all archives in the window of 7Zip portable (assigned as PL-LC)
- a PL-RC can extract your archives in place - as if you'd had the regular "Extract Here..." menu.


NOTES:

• The "Power" of this script depends on your ability to find the best apps and command lines to open your files. A few notes and examples are included in the default Definitions file.
• The Definitions file is a standard INI but it's not accepted by the board, so it's been renamed to XYS. You can leave it as is or rename its extension to ini as you see fit.
• Multiple items are directly supported through "OpenWith". They probably won't be processed through command-line (too much variation between apps).
:!: For direct SC access to specific Click/Associations (for Keyboard Shortcuts, etc.), the subs are "_LeftClick", "_RightClick" and "_DoubleClick", so use e.g.: load "PowerLauncher.xys", "_LeftClick";
:!: • PowerLauncher can be used to manage ALL your Double Click associations. Use at your own risk - though there's no reason it should break anything, and no slowdown can be noticed. Add the following entry on top in Tools > Customize File Associations: *>::load "PowerLauncher.xys";
(then copy your previous PFA associations to PL's Definition file).

• This script has become a terrible bloatware, I know... :oops: :mrgreen:

But first and foremost: Enjoy & don't hesitate to post your questions, suggestions, comments... 8)
Flux


---------------------
#############
### Update ###
#############

• Only download "PowerLauncher.xys" (if you already have "PowerLauncher-Definitions") and replace old.
• Have a look at the updated Definitions if you want to compare with yours.

• PL's Definitions file has been updated to use Primary and Secondary associations.
It's advised to download and use the new one, and copy/paste your associations from your old file.

• 1.5a3 > 1.5a4: Only comments about XYS have been updated in "PowerLauncher-Definitions", no need to update this file.

--------------------------
################
### Installation ###
################


I. INSTALLATION

To use this script, first, copy the two following files into XYplorer scripts folder: <xyscripts> ,
PowerLauncher.xys
(6.06 KiB) Downloaded 207 times
PowerLauncher-Definitions.xys
(2.36 KiB) Downloaded 216 times
then either:
1. add load "PowerLauncher.xys"; to the "on click" AND "on right-click" of your custom button, or

2. use the following snippet (with Don's litteral instructions):
-a) Paste ::snippet; into the address bar and press ENTER. A text box will open to enter snippet.
-b) And here comes the copy+paste ready snippet. It will create a new button at the right end of your toolbar.

Code: Select all

Snip: CTB 1
  XYplorer 11.60.0207, 05.10.2012 17:30:00
Action
  NewUserButton
Name
  Power Launcher
Icon
  :goprev
ScriptL
  load "PowerLauncher.xys";
ScriptR
  load "PowerLauncher.xys";
FireClick
  0
[/size]
II. EDITION

• Edit the Definitions file "PowerLauncher-Definitions.xys":
- Assign your favorite applications to the Left and/or Right Click and/or Double Click of the various categories (image, audio,...).
- If needed, add other categories (spreadsheet, database,...), with their associated filetypes (xls,db,...)
- If you're using XYplorer on different computers (portable mode), Assign your favorite portable applications to the Secondary associations.

--------------------------
################
### Changelog ###
################



v1.5a4
* Simplified association with XYS scripts
+ Added direct association to XYS subscripts (Labels)

v1.5a3
+ Added direct access to Left/Right/Double Click subscripts (for Keyboard Shortcuts, etc.)
+++ Added Secondary association option as fallback, if Primary association unavailable
+++ Added DoubleClick detection. For use with PFA catch-all (See notes) or other scripts
...If no association found or available, falls back to System default association
+ Added ability to run & parse file from other script by reading perm var $EXTCLICK = item path\name(s), e.g.
...perm $EXTCLICK = "<curitem>"; load "PowerLauncher.xys"; unset $EXTCLICK;
+ Added optional alternate INI file path (in <xydata>\[User])

v1.0b1
++ Added folder support
++ Added multiple items support
+ Added support for selected item(s) without focus
* Hugely optimized and streamlined code
Last edited by FluxTorpedoe on 13 Mar 2013 08:56, edited 2 times in total.

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.0 beta1]

Post by FluxTorpedoe » 20 Feb 2013 07:50

Hi there,

Some tips & shameless ad to celebrate this revision, with folders and multiple files/folders support:
- Try to use XYS as "direct openers" for your items. e.g. assign a Picture Metadata Renamer XYS to the right click of your folders, a specific virus command-line, etc.

Why Power Launcher?
Because with only 1 button you:
- clean your catalog from cluttering with OpenWith lines
- get the fastest extra-opener for your common files (e.g. have your pictures 2C-opened in XnView, and PL-opened in Photoshop)
- enhance your portability without having to modify then restore your PFA each time.
- And of course, because you can! :biggrin:

:arrow: Post your Best configs/combos!
Among my current favs/most-used are:
- LightAlloy as LC on videos (as my first portable ultralight player)
- Word as LC on docs (cause 2C runs the much faster TextMaker Viewer)
- MediaCoder as RC on audio
- XYS processed AntiVirus as RC on folders (cause I don't like resident AV)

Have a nice day! 8)
Flux

Enternal
Posts: 1171
Joined: 10 Jan 2012 18:26

Re: Power Launcher [v1.0 beta1]

Post by Enternal » 25 Feb 2013 17:59

Wow this is pretty neat! Thanks!

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.0 beta1]

Post by FluxTorpedoe » 26 Feb 2013 10:17

Glad you found it useful!
It takes a few days to get accustomed to it, but -especially in a portable environment- there's no match for this Power of Three! :D
(2C PortableFileAssociations + LC PowerLauncher + RC PowerLauncher)

kunkel321
Posts: 554
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Power Launcher [v1.0 beta1]

Post by kunkel321 » 11 Mar 2013 17:09

Pretty cool!

A while back someone had a feature request to add hotkey combos to button clicks.
i.e. not just <click> a button, but <ctrl+click>, <alt+click> etc.

This sortof adds that same type of thing to the PFA "Open With" button. :appl: :biggrin:
ste(phen|ve) kunkel

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

Re: Power Launcher [v1.0 beta1]

Post by highend » 11 Mar 2013 22:55

I'd like to use it with keyboard shortcuts instead of clicking on a button.

I know that looking for get("trigger") is a smarter detection for left/right mouse click but it doesn't allow
to execute the script with keyboard shortcuts (and emulate the left or right click).

Beginning of the script:

Code: Select all

"_LeftClick"
  global $Trigger;
  $Trigger = "LeftClick";
  sub "_Main";

"_RightClick"
  global $Trigger;
  $Trigger = "RightClick";
  sub "_Main";

"_Main"
  global $Trigger;
... Already existent code...

The "Input detection" part could be removed.

Ofc the snippet would have to replace with:

Code: Select all

Snip: CTB 1
  XYplorer 11.60.0207, 05.10.2012 17:30:00
Action
  NewUserButton
Name
  Power Launcher
Icon
  :goprev
ScriptL
  load "PowerLauncher.xys", "_LeftClick";
ScriptR
  load "PowerLauncher.xys", "_RightClick";
FireClick
  0
But it would allow the use of two different keyboard shortcuts to get both functionalites.

Comments?
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.5 alpha3]

Post by FluxTorpedoe » 12 Mar 2013 10:28

Good idea!
:arrow: Implemented.
But I didn't use a hidden "_Main" so no need to change the default button or snippet.

@all
I was a bit frightened the first time I used PL as the default runner for all files -with the "*" catchall from PFA- but I haven't noticed the slightest change in performance (on a crappy computer). A testimony to the robustness and flexibility of XYplorer!
So I'm getting used to having all associations managed in PL now - especially useful with the secondary possibilities... :wink:

Have a nice day, 8)
Flux

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

Re: Power Launcher [v1.5 alpha3]

Post by highend » 13 Mar 2013 00:10

Another idea: Let PowerLauncher call xys scripts (as apps for filetyes).

E.g. for video files:
Doubclick = just play with application
Rightclick = execute a .xys script, which converts this video

Possiblities are endless.

PowerLauncher.xys:

Code: Select all

*** D:\Users\Highend\Downloads\PowerLauncher.xys 2013-03-12 23:11:33.000000000 +0100
--- D:\Users\Highend\Tools\XYplorer\Data\Scripts\PowerLauncher.xys 2013-03-13 00:02:35.000000000 +0100
***************
*** 135,154 ****
--- 135,166 ----
  					$CL = replace($CL, '<curitem>', '$CurPath');
  				} else {
  					$CL = $App;
  				}
  				$CL = gettoken(eval("""$CL"""), 3, "|");
  				$App = gettoken(eval("""$App"""), 2, "|");
+ 			} elseif (gettoken(eval("""$App"""), 1, "|") == "SC") { // If application is a xys script
+ 				if isset($EXTCLICK) {
+ 					$SC = replace($App, '<curitem>', '$CurItem');
+ 					$SC = replace($SC, '<curitem>', '$CurPath');
+ 				} else {
+ 					$SC = $App;
+ 				}
+ 				$Type = "Script";
+ 				$SC = gettoken(eval("""$SC"""), 3, "|"); // Script label
+ 				$App = gettoken(eval("""$App"""), 2, "|");
  			} else {
  				$App = eval("""$App""");
  			}
  
  			if exists($App) { // If application exists
  
  				if isset($CL) { // If application has command line
  					run "$App $CL", "<curpath>", 2, 1;
+ 				} elseif ($Type == "Script") { // If application is a xys script
+ 					load "$App", "$SC"; // Empty labels are allowed
  				} else {
  					$items = regexreplace(<selitems>, '"\s"', "|");
  					$items = isset($EXTCLICK)? $EXTCLICK : regexreplace($items, '"', "");
  					openwith "$App", , $items;
  				}
  
and the "; --- 3 ---" part of the PowerLauncher-Definitions.xys file could be extended with:
; --- 3 ---
; Add path to executable for PL-LC or PL-RC or PFA-2C all (remove comment ";" when necessary)
;
; For apps with command-line, precede with 'CL|' and append with '| CommandLineArguments ""ItemOrPath""'
; !!! Enclose command-line vars with ""double quotes""
; !!! <selitems> is not supported
; arc=CL|<xypath>\..\PortableApps\7Zip\7za.exe| x ""<curitem>"" -o<curbase>
;
; To call xys scripts, precede with 'SC|' and append with '|LabelName'
; The appendix can be omitted if you call a script without a label
; vid=SC|<xyscripts>\VideoConvert.xys|HiQuality
I didn't test the "if isset($EXTCLICK) {" part of the "} elseif (gettoken(eval("""$App"""), 1, "|") == "SC") {" condition!
If you like, review the changes and incorporate them.

Regards,
Highend
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.5 alpha4]

Post by FluxTorpedoe » 13 Mar 2013 09:05

Another good idea, thanks! :)

I tried to keep things simple, so XYS can be used like standard apps, w/ or w/o CL.
(I ended adding only this crappy detection in the middle of the code)

Code: Select all

	if ($App Like "*.xys") {
		$CL = isset($CL)? $CL : "";
		load "$App", "$CL";
		end 1==1, , 1;
	}
[/size]
As you said, with 3 Clicks running (Exe | Scripts^Labels), possibilities really are endless! :biggrin:
Well, go ahead if you have other ideas!... 8)

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

Re: Power Launcher [v1.5 alpha4]

Post by highend » 13 Mar 2013 10:20

Well, go ahead if you have other ideas
Well...

There is one more thing that I'd like to have:
The ability to define several different applications for a filetype.

Either by adding a second divider (because it should still work with command line applications / scripts with labels) to a file type definition like:
vid=<xydrive>\Tools\VLC\vlc.exe!<xydrive>\Tools\LightAlloy\LA.exe
or by doubling that line like:
vid=<xydrive>\Tools\VLC\vlc.exe
vid=<xydrive>\Tools\LightAlloy\LA.exe
I'd prefer the first method ;)

Atm it's possible to define an application with double / left and rightclick, so you could have 3 variations at max. But it's probably hard to remember which application was associated with which click.

By adding the possibility to define more than one app for a filetype, you can let the user select the one he wants.
Either by inputselect() (preferred method) or by popupmenu().

And that's where the possibilities are really becoming endless :)

A real world example (I've removed the "-PRIMARY" part, it wouldn't be needed anymore):
[PowerOpenerLeftClick]
vid=<xydrive>\Tools\VLC\vlc.exe!<xydrive>\Tools\LightAlloy\LA.exe!<xydrive>\Tools\MediaPlayer Classic\mpc-hc.exe
Parsing that line would lead to (if all three applications really exist):
Unbenannt1.png
Unbenannt1.png (13.28 KiB) Viewed 5021 times
The first app in that list (that exists) should be prefixed with a "+" to select it by default, so that you can always put the most wanted application at the first place.

Btw, this would allow you / us to get rid of the -SECONDARY categories in the PowerLauncher-Definitions...

Regards,
Highend
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.5 alpha4]

Post by FluxTorpedoe » 13 Mar 2013 13:30

Well, I think this function would especially make sense with PL's RC, either for those extra apps that can't fit, or simply as a reminder of the apps that can be run... Thanks highend for those ideas, but before I release it,

@all
If you wanna try:
• Just after

Code: Select all

		if $App { // If application defined
add this:

Code: Select all

			if (eval("""$App""") Like "*[?]*") { // If multiple applications
				set $l_Apps;
				foreach($x_App, eval("""$App"""), "?") {
					if ((exists($x_App)) || (exists(gettoken($x_App, 2, "|"))) || (exists("<xyscripts>\$x_App")) || (exists("<xyscripts>\".gettoken($x_App, 2, "|")))) {
						$x_App = replace($x_App, "CL|", "");
						$x_App = replace($x_App, "|", "<tab>");
						$l_Apps = $l_Apps.$x_App."?";";<tab>", ";")."?";
					}
				}
				$App = ($l_Apps)? inputselect("Select application to open:<crlf>   $CurItem<crlf>", $l_Apps, "?", 1, , , , "PowerOpener") : "";
				$AppTmp = replace($App, "<tab>", "|");
				$App = ($AppTmp != $App)? "CL|$AppTmp" : $App;
			}
• In you Definitions file, add several apps separated by a question mark "?", or just add a question mark at the end of a line to have a reminder of a rarely-used app, e.g.
vid=<xydrive>\Tools\VLC\vlc.exe?<xydrive>\Tools\LightAlloy\LA.exe
unk=%temp%\ShowMeYourNamePlease.exe?


@highend
That said, I certainly wouldn't discard the Primary/Secondary approach, because interface-wise, I tend to favor efficiency before all, and/or have some logic to support it, i.e. to be able to act without thinking or choosing. :P
And that's why I implemented this duality: I know what a DoubleClick will launch (I guess we all do :wink: ), and if it's not available, I know I want the next best thing to launch - and not a Menu.
Same goes for PowerLauncher's LeftClick which I use mainly for "heavy" apps; available or not, I don't want to choose, I want it now! 8)

But for PL's RC (which I use mainly as a ContextMenu supplement), a multi-choice makes sense!
So I jumped on your idea, I used the "?" instead of "!" (less risky, can't be used in paths) and inputselect without checkboxes so only one app can be chosen (the first gets auto-focused but not auto-selected unfortunately).

Tell me what you think...

EDIT: Fixed detection of CommandLine Apps and scripts
Last edited by FluxTorpedoe on 14 Mar 2013 14:58, edited 6 times in total.

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

Re: Power Launcher [v1.5 alpha4]

Post by highend » 13 Mar 2013 14:39

@FluxTorpedoe

I agree with you that it makes more sense to use multiple application assignments for the rightclick, instead of left or doubleclick.
I (personally) use 95% portable applications by default, so I don't really need the -SECONDARY category but I'm probably not the average user ;)
Just leave it as it is, maybe there are enough people who can make use of a "fallback" application when running XY from a stick.

You need to revise the code for the multiple applications parsing.
Problems:
1. A .xys script won't be found at all if you don't define a path for it
2. A .xys script with a label doesn't work because it won't find the script (because of the label which is treated like part of the full filename)

Regards,
Highend
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

FluxTorpedoe
Posts: 707
Joined: 05 Oct 2011 13:15

Re: Power Launcher [v1.5 alpha4]

Post by FluxTorpedoe » 13 Mar 2013 14:59

Funny, I was just updating the code to support multiple scripts with labels... ;)
So I just extended this line (I updated my previous post with it):

Code: Select all

	if (exists($x_App) || ($x_App Like "*.xys") || (gettoken($x_App, 2, "|") Like "*.xys")) {
I don't know if that solves the issues you were mentioning, let me know. Working good here... Well, except it looks ugly in InputSelect. :) Maybe later for some cosmetics.

As for portability, I'm a big fan too cause I need it, but I'm stuck at about 75%, the rest being un-portable for me (usually because the performance trade-off on a small computer is too big). :?
Anyway, the Secondary fallback is checked only if Primary app is not found, so no slowdown.

Edit: Code wasn't strong enough - Updated previous post and added "cosmetics"

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

Re: Power Launcher [v1.5 alpha4]

Post by highend » 13 Mar 2013 15:55

Updated code looks good so far.

Hint:
You could easily replace 3 lines by one...

Code: Select all

$x_App = replace($x_App, "CL|", "");
$x_App = replace($x_App, "|", "<tab>");
$l_Apps = $l_Apps.$x_App."?";
With:

Code: Select all

$l_Apps = $l_Apps.replacelist($x_App, "CL|;|", ";<tab>", ";")."?";
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: Power Launcher [v1.5 alpha4]

Post by highend » 13 Mar 2013 21:52

Just stumbled upon an issue...

Just one PFA: *>::load "PowerLauncher.xys";

I have defined one (among several) commands via:
User - Manage Commands...
Open
Item: "D:\Tools\AutoHotKey_L\AutoHotkey.exe" "D:\Tools\AutoHotKey_L\.Scripts\.Startup\AHK_startup.ahk"

Which was working fine before I added the PowerLauncher PFA.

When I want to invoke that command I get
"No item selected to open" in the status bar.

Sure, that's correct, no item is / was selected...

Any workaround available?
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Post Reply