Add custom commands to context menu ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Stef123

Re: Add custom commands to context menu ?

Post by Stef123 »

CookieMonster wrote: I'm trying to get your example working; as you mentioned it is a few too many clicks
You are right - that's what I am saying. Too many clicks.
It is a workaround, and it has some other limitations. But never mind. You got it working or not?

CookieMonster

Re: Add custom commands to context menu ?

Post by CookieMonster »

Stef123 wrote:
CookieMonster wrote: I'm trying to get your example working; as you mentioned it is a few too many clicks
You are right - that's what I am saying. Too many clicks.
It is a workaround, and it has some other limitations. But never mind. You got it working or not?
I don't understand how to reverse it as you mention ?
Also not logical :naughty: , to have your context menu as part of Open with..... - it should be the other way round. Or at least side by side, so you can place custom calls next to Open with ..

Stef123

Re: Add custom commands to context menu ?

Post by Stef123 »

Forget it. One HUGE misunderstanding.
Does it work? Then be happy with it.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Add custom commands to context menu ?

Post by bdeshi »

If least possible clicks is the objective then how about this: right click empty list area. If anything is selected your custom menu comes up, else whatever you usually get when right-clicking empty list area.

Code: Select all

; Tweak: 0=Edit menu, 1=Folder's shell menu, 2=Favorites, 3=reserved, 4=Tabs, 5=FavFiles, 6=Script
CEA_ListRightClickOnWhite=6
CEA_ListRightClickOnWhite_Script=::if (get('CountSelected') > 0) { load "MyContextMenu.xys",,f; } else { popupmainmenu 'edit'; } ;
the else {} block corresponds to CEA_ListRightClickOnWhite=0

other correspondences (replaces popupmainmenu 'edit'; )

Code: Select all

2: #550 / 4: #690 / 5: #564 / 1: focus 'T';sendkeys '+{F10}';focus 'L';
the last one shows current folder's ctx menu, it's a bit unstable as you have to have the tree visible, and set CEA_TreeListDoubleClickOnWhite=0 :whistle:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Re: Add custom commands to context menu ?

Post by klownboy »

With a little scripting (well maybe not just a little ) a user could set-up the "MyContextMenu.xys" such that it brought up a different menu dependent on what file type is currently selected. If a JPG is selected it would bring up a selection of image programs (e.g., ImageEye, Irfanview, etc.) to open the file. If an AVI or MP4 video file was selected it could bring up a different menu with video choices, Media Player, VLC, etc.). This way, the right click on white (or maybe at some point a middle click) would bring up a more file-type specific menu.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

CookieMonster

Re: Add custom commands to context menu ?

Post by CookieMonster »

Can this script feed in all the commands of a command line program into a context menu for example; I right click anywhere in a pane, or even on a file, my command line program is listed, as well as options, I select the command line option which is associated with the command, in the context menu and the operation is run, done ?
SammaySarkar wrote:If least possible clicks is the objective then how about this: right click empty list area. If anything is selected your custom menu comes up, else whatever you usually get when right-clicking empty list area.

Code: Select all

; Tweak: 0=Edit menu, 1=Folder's shell menu, 2=Favorites, 3=reserved, 4=Tabs, 5=FavFiles, 6=Script
CEA_ListRightClickOnWhite=6
CEA_ListRightClickOnWhite_Script=::if (get('CountSelected') > 0) { load "MyContextMenu.xys",,f; } else { popupmainmenu 'edit'; } ;
the else {} block corresponds to CEA_ListRightClickOnWhite=0

other correspondences (replaces popupmainmenu 'edit'; )

Code: Select all

2: #550 / 4: #690 / 5: #564 / 1: focus 'T';sendkeys '+{F10}';focus 'L';
the last one shows current folder's ctx menu, it's a bit unstable as you have to have the tree visible, and set CEA_TreeListDoubleClickOnWhite=0 :whistle:

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Add custom commands to context menu ?

Post by bdeshi »

if that's all you want then you should at least give more data? What's this cmdline program? which of it's options do you want available? Should it work with selected files/current folder/something else?

this would be the skeleton of the script you'll need:

Code: Select all

"Option 1"
  run quote("program.exe") . " /commands" . " -commands". quote(<file>) . " - more commands"
"Option 2"
  run quote("program.exe") . " -c -o -m -m -a -n -d -s" . " -other -cmd". quote(<files>) . "no " . "more commands" . " please";
!!THIS SCRIPT WONT DO ANYTHING (MEANINGFUL) YET!!

Also, you can just plug the script into a custom toolbar button. Then clicking the button will always show that menu. Just one click.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

CookieMonster

Re: Add custom commands to context menu ?

Post by CookieMonster »

What is the intention of your script, first of all, then we'll get all organized :)
SammaySarkar wrote:if that's all you want then you should at least give more data? What's this cmdline program? which of it's options do you want available? Should it work with selected files/current folder/something else?

this would be the skeleton of the script you'll need:

Code: Select all

"Option 1"
  run quote("program.exe") . " /commands" . " -commands". quote(<file>) . " - more commands"
"Option 2"
  run quote("program.exe") . " -c -o -m -m -a -n -d -s" . " -other -cmd". quote(<files>) . "no " . "more commands" . " please";
!!THIS SCRIPT WONT DO ANYTHING (MEANINGFUL) YET!!

Also, you can just plug the script into a custom toolbar button. Then clicking the button will always show that menu. Just one click.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Add custom commands to context menu ?

Post by bdeshi »

:veryconfused:
CookieMonster wrote:Can this script feed in all the commands of a command line program into a context menu for example; I right click anywhere in a pane, or even on a file, my command line program is listed, as well as options, I select the command line option which is associated with the command, in the context menu and the operation is run, done ?
sammaysarkar wrote:this would be the skeleton of the script you'll need:
I just demonstrated what type of script you can expect.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: Add custom commands to context menu ?

Post by Stef123 »

@ Sammay and Ken,
right-clicking on white is already taken up in my case - with favorites. I wouldn't want to give up on that, especially since I have Sammay's script to add dual favorites on the fly. And I find it counter-intuitve to right-click white in order to do s.th. with a selection - everywhere else it requires right-clicking on the selection itself, not in the white space.

But that's just me. It might help CookieMonster better than taking the route via "Open with.."
Your approach has many advantages over mine. It's more direct, on the first click. And it allows better organizing with separators and whatever else is not possible in the "Open with..." dialog.

Ultimately, I'd love to see customized mouse actions in XY - it'd be a nice complement to shortcuts. Nothing faster than clicking AND pressing shortcuts, combining modifier keys and acclerators with left/ right clicking. :P

klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Re: Add custom commands to context menu ?

Post by klownboy »

Stef123 wrote:Right-clicking on white is already taken up in my case - with favorites. I wouldn't want to give up on that...
I know what you mean. I have my Vertical Toolbar script assigned to right click on white. What I'm thinking of doing though is setting up a different script that would bring up a specific menu based on the file selected (i.e., the <curitem> actually <curext>) as I explained above (i.e., different menus for different file types - all automatic). If no file is selected (or you simply standard left click on white first before right click), then a default menu like my Vertical Toolbar or your Favorites Menu displays. It could even bring up a different menu if a folder is selected or it could immediately start a second instance of XY in a certain layout, thumbnails size, etc for the contents of that folder. I think that could be useful.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Add custom commands to context menu ?

Post by Stef123 »

klownboy wrote:
Stef123 wrote:Right-clicking on white is already taken up in my case - with favorites. I wouldn't want to give up on that...
I know what you mean.
.... bring up a different menu if a folder is selected...
:idea: :idea: - After re-reading your postings (and Sammay's) it finally begins to dawn on me, too :whistle: - you'd be setting the tweak to 6 - then, if no selection ist active - call up favorites "manually", via command in your decision.xys. The question is, will it still come up at the mouse-pointer? And will it also work on "Location not available" - these 2 prerequisites are very important to me.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Add custom commands to context menu ?

Post by bdeshi »

Stef123 wrote:The question is, it still come up at the mouse-pointer? And will it also work on "Location not available" - these 2 prerequisites are very important to me.
1) yes and 2) yes!
1) as long as this is is true: <xyini>\[Settings]\PopupMenusAtSelection=0
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Re: Add custom commands to context menu ?

Post by klownboy »

Thanks for the reminder Sammay on that setting for bringing up menus like Favorites Files or Favorite Folders at the current mouse position.

So it seems to be working quite nicely, in that if I have a particular file selected (e.g., certain extension(s)), a menu comes up with actions associated with the file extension. If no file is selected or the file extension doesn't match one of the file types, then a default menu will display like "Favorites". All the menus surface where the cursor is located. I may set it up such that if a folder is selected it will bring up some key options on various layout and thumbnail size combinations to display the folder in a new or existing instance of XY. Of course this is the type of script that everyone would have different file associations and default menu so it wouldn't be universal. I can post an example though.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Add custom commands to context menu ?

Post by Stef123 »

@Sammay,
yes, the tweak is set to =0
klownboy wrote: I can post an example though.
Yes, please do this, Ken. I must try to see how I get along, although it goes against all grains to right-click in the white instead onto the selection. In other apps this will make you lose your selection instead of working on it.

Post Reply