INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: New Links Action: External Program?  (Read 1831 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
New Links Action: External Program?
« on: June 30, 2022, 10:51:48 pm »

Hey everyone. Long time, no type. Yada yada yada.

Finally getting around to setting up MC29 on my server, and I have a request: I'd like a new "type" of Link which launches an External Program instead of just a browser.

The Links bar in Standard View is great. I love it and I have a whole variety of useful Links set up in there with nice filters so they're handy for various tasks and browsing.

However, in some cases, I want to run an external program (almost always a script) instead of launching a Browser with the specified URL. Just like Send To > External except filtered like the Links are (so it only shows when relevant and useful) and on the handy Links bar where my other similar tools live. I'd love it if this could be added. You could simply add a new Action: External Program and, when it is selected, change Base URL to a file-picker and change/use the Search URL's textbox for the Argument field.

In addition to my crazy scripts, I can think of many regular human ways this would be useful. If you often edit your photos in Photoshop or whatever, you could add a Link (which would only appear if Photos are selected in the view) to launch them in Photoshop. You could open Video files with MediaInfo. Process files with MKVToolnix. All kinds of handy dandy bits and bobs.

PS. And while you're in there, Folders (limited to one tier only is fine by me) for our Links would make me a very happy boy. My bar gets a bit crowded up there sometimes.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #1 on: June 30, 2022, 11:10:33 pm »

The main reason I actually want this is that, as I mentioned, I have a bunch of handy Links that do cool stuff. For example, I have a link that'll open a search to the Memory Alpha article for an episode of Star Trek, but which only shows up if you actually have an episode of Star Trek selected:

Code: [Select]
<Link version="1.2">
<Item Name="Name">Memory Alpha</Item>
<Item Name="Action">1</Item>
<Item Name="Base URL">https://memory-alpha.fandom.com</Item>
<Item Name="Search URL">https:////memory-alpha.fandom.com//wiki//Special:Search?query=Hexify([Name])+(episode)&amp;scope=internal&amp;navigationSearch=true</Item>
<Item Name="Filter">[Media Type]=[Video] [Media Sub Type]=[TV Show] [Series]="Star Trek"</Item>
</Link>

But many of them I use when I'm doing maintenance on my Library. Fixing metadata, replacing crappy or broken files, and things like that.

So, anyway, there is a certain set of these URLs that I used for years, but for various security reasons, I don't actually launch those pages directly on the Server or Client machines anymore. Instead, I do these tasks in an isolated VM running on the server. But this has always been a pain in the butt. I have those awesome Links in MC which will take me directly to the page I need, but does so on the wrong PC. It went on like this for the past couple of years, and I've just been muddling through copypasta style.

Well, I finally got off my own butt and wrote a script that takes a few command line switches so you can specify the URL and search you want to use, and uses vmrun to launch the browser to that page within my VM (instead of on my server directly).

This works fine in the Send To > External right-click menu, but that is buried a few layers deep and it doesn't filter itself based on selected files like the Links bar does, which makes me a sad boy. And, in this particular case, it even "feels wrong" because I am launching a browser (just like all the other Links), just on a different "computer".
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

comox

  • Galactic Citizen
  • ****
  • Posts: 428
Re: New Links Action: External Program?
« Reply #2 on: July 01, 2022, 12:30:52 am »

I like it.

And that guy that wants to watch Roadrunner cartoons can launch VLC.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: New Links Action: External Program?
« Reply #3 on: July 01, 2022, 06:01:39 am »

You know that file:// urls can be used to open applications? The below link opens notepad.
The problem is that file:// cannot take arguments. However, a handler can be created that works like file:// and also takes args ;)
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: New Links Action: External Program?
« Reply #4 on: July 01, 2022, 07:05:59 am »

Well, this totally works  ;D
I wrote a protocol handler called mcrun:// that can run any app from a browser or MC.

https://github.com/zybexXL/MCRun/releases/tag/v1.0

- download the EXE, place it anywhere
- run it once - it will register the "mcrun://" handler
- close it (or play with it - click "?" in the app to learn about usage)
- setup Links in MC as shown in the screenshot. Don't forget to set "open in external browser"

You owe my employer 2 hours of my time :P

PS: I'd like to see Folders in the Link area as well. It's just too small to fit more than 4 or 5 links. It would also be great to have icon or <img> support (to show an icon instead of text - fits many more), and <font> to change the text color :) <Font> actually changes the color on the Link editor control, but not on the actual link bar.

PS2: It's of course better if MC implements the Executable links directly. This was more like a proof of concept.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: New Links Action: External Program?
« Reply #5 on: July 01, 2022, 08:51:53 am »

PS: I'd like to see Folders in the Link area as well. It's just too small to fit more than 4 or 5 links. It would also be great to have icon or <img> support (to show an icon instead of text - fits many more), and <font> to change the text color :) <Font> actually changes the color on the Link editor control, but not on the actual link bar.
I have suggested before  a toolbar item which would show links as a dropdown list similar to eg zones
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #6 on: July 01, 2022, 09:26:35 am »

Well, this totally works  ;D
I wrote a protocol handler called mcrun:// that can run any app from a browser or MC.

https://github.com/zybexXL/MCRun/releases/tag/v1.0

Hahaha! I considered doing exactly that. Here's the problem, though.... Now I can get a shell on your machine by getting you to click on any URL link (and maybe just by sending you an image tag). So, yeah, that's non-ideal.

Of course, I'd have to know you have that little applet installed (and clicking on unknown links is bad anyway) but still doesn't give me the warm-fuzzies. That said, if we don't get it built-in, I might be persuaded to use it.


Perhaps not, depending on how you did it. I'll have to check it out.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #7 on: July 01, 2022, 09:39:29 am »

PS: I'd like to see Folders in the Link area as well. It's just too small to fit more than 4 or 5 links. It would also be great to have icon or <img> support (to show an icon instead of text - fits many more), and <font> to change the text color :) <Font> actually changes the color on the Link editor control, but not on the actual link bar.

I'd like both of your two things listed above too, but I figured that was asking for the world.

Since we are, though, one other little tweak worth bringing up:
Right now, when you have multiple files selected (or, more frequently for me, no files at all selected in a View, and so therefore "all" selected), the Links behave as if the searches are ORed with each other. The link shows if any item in the selection matches.

I'd prefer it if when there were multiple selections, the Links showed only if the Searches for them are ANDed with each other (Link only shows if the condition matches for ALL selected files).

That way, when I open up Views that contain many different files, I don't end up with:


There's no way to use the links with multiple files selected if they don't actually all match anyway. So it makes more sense visually and functionally to switch this behavior.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: New Links Action: External Program?
« Reply #8 on: July 01, 2022, 02:47:16 pm »

Hahaha! I considered doing exactly that. Here's the problem, though.... Now I can get a shell on your machine by getting you to click on any URL link
Perhaps not, depending on how you did it. I'll have to check it out.

Non-standard handlers are not recognized as valid links, so this is not clickable:
mcrun://shell/echo/pwned!/&pause

Event using the [ url] tag doesn't work - The forum supresses the ':', and if you force it Chrome blocks the link:
click here!

You would have to copy the command, paste it on your browser manually, and then accept the security prompt, thus shooting yourself in the foot.
Also, who would bother to create an exploit for mcrun:// which will be used by all of 7 users worldwide? ;D
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #9 on: July 01, 2022, 07:54:31 pm »

Yeah. Hence crossed out.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #10 on: July 08, 2022, 07:47:24 pm »

Bumpity
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72444
  • Where did I put my teeth?
Re: New Links Action: External Program?
« Reply #11 on: July 09, 2022, 07:33:18 am »

There's been a lot of discussion in the thread.  Can you re-state the request?

If it's still the same as the first post, it seems like it could be a lot of work on a messy task that might not have wide appeal.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #12 on: July 09, 2022, 05:39:14 pm »

There's been a lot of discussion in the thread.  Can you re-state the request?

Sure thing! Really quite simple: I'd like to make a few Links that open an External Program, instead of a web page.

This functionality is something MC can already do in the Send To > External menu. But that menu doesn't filter itself based on the selected items in the View like Links do, and it is buried deeply in the right-click menus and difficult to access.

I don't think this would be a niche feature at all. I can think of many convenient uses for it: Opening photos in your favorite photo-editor, for example, or a home video in a movie editor. Or just specifying a particular browser that you want to use for some links instead of the internal or system default browser.

I also don't know your code at all, of course, but since MC can already launch external programs and pass them command line parameters based on the selected file, and since the Links buttons are already doing very much the same thing (opening an external browser and passing it a command line parameter based on the selected file), it doesn't seem like that much of a heavy lift. And the GUI implementation doesn't need to be that complicated either:

* A new Action available in the Action Dropdown: Open External Program

* When this is selected, the Base URL field turns into Program Path (a file-path/browse box) and Search URL turns into Parameters. Exactly like Send To > External.

* Everything else in the dialog would work exactly as-is. Those two fields I mentioned above should even stay exactly like they are sized and whatnot now, except renamed (and with the little file-browse button added to the former).

If you wanted to, and think people wouldn't scream, you could remove the Send To > External menu item because this would do everything that does, but better, and easier to access. I'd move all of mine to the Links and forget about Send To > External, for sure. But, you know, we people like to scream so... Meh. Also wouldn't hurt to leave it.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42385
  • Shoes gone again!
Re: New Links Action: External Program?
« Reply #13 on: July 10, 2022, 10:25:48 am »

I think this is a good idea.  I can probably hook it up this week.  Thanks.
Logged
Matt Ashland, JRiver Media Center

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #14 on: July 14, 2022, 06:42:47 pm »

I think this is a good idea.  I can probably hook it up this week.  Thanks.

Thanks!!
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: New Links Action: External Program?
« Reply #15 on: July 15, 2022, 02:43:03 pm »

I got the chance to get this set up this afternoon and it works perfectly. Thanks! I'll try to post a "reward" later.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up