How to create a file type specific OpenWith context menu

Discuss and share scripts and script files...
Post Reply
admin
Site Admin
Posts: 60603
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

How to create a file type specific OpenWith context menu

Post by admin »

[from v7.00.0009 onwards]

It took me 3 minutes to create something which will save me hours and hours from now on! Because now, when I dbl-click an Image file (or press Enter on it), I get a little popup menu that allows me to choose the app to open the image with! :D Here's how:

Step 1
Create a new script file called OpenImages.xys in a subfolder "Scripts" of your application data path. In my case this would be E:\XY\XYplorer\Scripts\.

Paste this into the file and save it:

Code: Select all

"Open Image(s) with &ACDSee"
  OpenWith ACDSee32, m;
"Open Image(s) with &ImageReady"
  OpenWith ImageReady;
"Open Image(s) with &Photoshop"
  OpenWith Photoshop;
-
"Cancel"
Step 2
Open menu Tools | Customize File Associations... and create a new one looking like this:

Code: Select all

jpg;png;gif>::load <xydata>\Scripts\OpenImages.xys
That's it! Provided you have the applications that are referred to in OpenImages.xys, it should work for you just as it works for me.

j_c_hallgren
XY Blog Master
Posts: 5824
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

And what value would one put for other apps in OpenWith? :?

Like Irfanview, etc?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

admin
Site Admin
Posts: 60603
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Post by admin »

j_c_hallgren wrote:And what value would one put for other apps in OpenWith? :?

Like Irfanview, etc?
You can either put the full path to the EXE, or, if the app is registered, usually the exe base name is enough. (I don't know what that is with irfanview).

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: How to create a file type specific OpenWith context menu

Post by serendipity »

admin wrote:[from v7.00.0009 onwards]

It took me 3 minutes to create something which will save me hours and hours from now on! Because now, when I dbl-click an Image file (or press Enter on it), I get a little popup menu that allows me to choose the app to open the image with! :D Here's how:

Step 1
Create a new script file called OpenImages.xys in a subfolder "Scripts" of your application data path. In my case this would be E:\XY\XYplorer\Scripts\.

Paste this into the file and save it:

Code: Select all

"Open Image(s) with &ACDSee"
  OpenWith ACDSee32, m;
"Open Image(s) with &ImageReady"
  OpenWith ImageReady;
"Open Image(s) with &Photoshop"
  OpenWith Photoshop;
-
"Cancel"
Step 2
Open menu Tools | Customize File Associations... and create a new one looking like this:

Code: Select all

jpg;png;gif>::load <xydata>\Scripts\OpenImages.xys
That's it! Provided you have the applications that are referred to in OpenImages.xys, it should work for you just as it works for me.
Neat. 8)

admin
Site Admin
Posts: 60603
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: How to create a file type specific OpenWith context menu

Post by admin »

serendipity wrote:Neat. 8)
Yep, but it lead me to something even neater: tomorrow you get the same functionality even without any script file... 8)

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: How to create a file type specific OpenWith context menu

Post by serendipity »

admin wrote:
serendipity wrote:Neat. 8)
Yep, but it lead me to something even neater: tomorrow you get the same functionality even without any script file... 8)
Glad you told me that, i was going to make lot of changes.

OK, the popup of user-defined list is cool, but I dont want it to appear on double-click. Because when i am going to click a file i already know what app i want to open it with and i would reserve double-click to open an item with default app (or first app in my created list). Typically right-click is for open-with (but right-click gives the regular context menu), so how about shift or ctrl right-click?
or, like there is the revolutionary new items, how about showing custom apps in the regular "right-click>open with" depending on filetype?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: How to create a file type specific OpenWith context menu

Post by jacky »

serendipity wrote:OK, the popup of user-defined list is cool, but I dont want it to appear on double-click. Because when i am going to click a file i already know what app i want to open it with and i would reserve double-click to open an item with default app (or first app in my created list). Typically right-click is for open-with (but right-click gives the regular context menu), so how about shift or ctrl right-click?
Or, you could just wait for the ability for us to load a script file on middle-click on List (among other actions, like another one on dbl-click on List, others for middle/dbl-click on Tree, ...) and write a script that would pop-up a menu depending on the current item !

Code: Select all

regexreplace $ext, <curext>, "(avi|mpg|vob|ts)", "OpenVideos";
 regexreplace $ext, $ext, "(jpe*g|png|gif|bmp)", "OpenPictures";
 regexreplace $ext, $ext, "(doc|xls)", "OpenOffice";
 regexreplace $ext, $ext, "^(?!Open).+", "OpenCommon";
 msg "load $ext;";
BTW & OT, not really a bump but here we go, with an issue that doesn't allow scripts on PFA to be used at their most powerful. I mean, as long as the script used on PFA is nothing but a openwith with parameters, or pops up a menu with different openwith possibilities, I guess it's fine.

But there's more than can be done than that, except that for now it's limited to only one file at a time...
Proud XYplorer Fanatic

j_c_hallgren
XY Blog Master
Posts: 5824
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: How to create a file type specific OpenWith context menu

Post by j_c_hallgren »

serendipity wrote:OK, the popup of user-defined list is cool, but I dont want it to appear on double-click. Because when i am going to click a file i already know what app i want to open it with and i would reserve double-click to open an item with default app (or first app in my created list). Typically right-click is for open-with (but right-click gives the regular context menu), so how about shift or ctrl right-click?
or, like there is the revolutionary new items, how about showing custom apps in the regular "right-click>open with" depending on filetype?
Well...I have four choices for JPG via the M$ OS "Open With" context menu (IE/IrfanView/Paint.Net/Elements), but I created a script like above instead....why? Because...on my touchpad, I can now access the desired pgrm via tapping only without having to do a right-click and then moving down thru the menu to get there, so it's definitely quicker! :D

Even though it doesn't automatically open a default pgrm, it's only a very short movement to the first entry in list and one more tap, and I'm there but I also had the choice available with no unusual finger movements. :D

So...if y'all can make it even better, fine, but please don't make it harder than it is now, as then I'll be back to the way it was before...and be :(
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

admin
Site Admin
Posts: 60603
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: How to create a file type specific OpenWith context menu

Post by admin »

j_c_hallgren wrote:
serendipity wrote:OK, the popup of user-defined list is cool, but I dont want it to appear on double-click. Because when i am going to click a file i already know what app i want to open it with and i would reserve double-click to open an item with default app (or first app in my created list). Typically right-click is for open-with (but right-click gives the regular context menu), so how about shift or ctrl right-click?
or, like there is the revolutionary new items, how about showing custom apps in the regular "right-click>open with" depending on filetype?
Well...I have four choices for JPG via the M$ OS "Open With" context menu (IE/IrfanView/Paint.Net/Elements), but I created a script like above instead....why? Because...on my touchpad, I can now access the desired pgrm via tapping only without having to do a right-click and then moving down thru the menu to get there, so it's definitely quicker! :D

Even though it doesn't automatically open a default pgrm, it's only a very short movement to the first entry in list and one more tap, and I'm there but I also had the choice available with no unusual finger movements. :D

So...if y'all can make it even better, fine, but please don't make it harder than it is now, as then I'll be back to the way it was before...and be :(
Yes, I like that, too. Also, there is no free combination like Ctrl+RightClick available AFAIK.


:!: BTW, I just found a little issue with the trick I showed in this thread:

dblclick on one selected file: okay
[enter] on one selected file: okay
dblclick on more than one selected file: okay
[enter] on more than one selected file: not okay!

In the last case, there will be a stupid double loop (the popup menu and the following Open all selected items is done for each selected item! :( ), and with the current means, I don't see a programmatical way to prevent this. (A possible solution would be to load script files with arguments <param1> <param2> etc that could be used by the scripts contained in the file... maybe later...)

Workaround: if you want to use this trick on multiple files using the keyboard, press [Ctrl+Enter] (which is the equivalent to dbl-click in this context) to avoid that you get popup menu for each selected file.

However, since this workaround is not really cool, I will for the time being refrain from implementing the other idea I had (namely to do a similar trick even without using a script file) because it would essentially meet the same problem...

Post Reply