Assigning external programs to the Keyboard Funtion Keys

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

Is it possible to assign a program exe to a function key so that it will be executed on
the currently selected file in a directory listing?

For example, If I want to browse or edit a file, I simply would use F2 or F4 against the file
to either edit or browse that file. My current file manger allows me to do this which is very
convenient and quick. I can also open a cmd line to execute an item with additional parms.
I.e. the command line would look like this: / 12345 The slash refers to the current item in
the dir listing and the rest would be parameters.

I just came across XYPlorer and see that it has a lot of bells and whistles and was wondering
if what I want to do is also possible.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Assigning external programs to the Keyboard Funtion Keys

Post by highend »

Welcome to the forum

Sure that's possible...

An example:
UDC.png
This one opens a command prompt (without exiting it when the program has finished) and calls
the current selected file with the param: --version.

So if I'd use it on git.exe it would display the output of git.exe --version afterwards
You can assign keyboard shortcuts to such a user-defined command

The help file - Advanced Topics - User-Defined Commands should tell you the necessary details...
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Re: Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

Sounds good, I will do some testing. I did notice that you cannot reassign the Enter key. I normally use that
for browsing files. Is there a specific reason why the Enter key cannot be reassigned to run an external program?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Assigning external programs to the Keyboard Funtion Keys

Post by highend »

Probably hardcoded to all the functions it already has (executing files/opening non-executables, folders...)
One of my scripts helped you out? Please donate via Paypal

click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Re: Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

I just tried this as a quick test when running from XYPlorer, but the window closes and I don't see any output.
run 'cmd /k fv.exe <curitem>' ;

If I run the same command from the Windows Run box, I see the output in the console window and it
doesn't close. cmd /k fv.exe c:\_AppTweak.log

Is my syntax wrong?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Assigning external programs to the Keyboard Funtion Keys

Post by highend »

Single quotes -> No variable resolving -> <curitem> = literal "<curitem>"
One of my scripts helped you out? Please donate via Paypal

click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Re: Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

Thanks, I got that working now. There's a lot to read and learn. One thing I haven't found yet is how to run <curitem> where I can still edit the parameters. I don't want to hard-code multiple scripts for each possible parameter. I could use run "<curitem> <clp>"; but I would still like to see the entire cmdline and possibly edit the <clp> part before running it. An editable CmdLine Bar like the Address Bar would be ideal. I don't think Step Mode would help here. Any way to do this?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Assigning external programs to the Keyboard Funtion Keys

Post by highend »

Code: Select all

input()
is the necessary scripting command
One of my scripts helped you out? Please donate via Paypal

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

Re: Assigning external programs to the Keyboard Funtion Keys

Post by admin »

Tip: The "Open With" category in User-Defined Commands is meant to do exactly this.

click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Re: Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

Thanks for the tips. I'm a bit overwhelmed at all the possibilities available, and find it difficult to always find
what I'm looking for and implement it. Eventually, I will have less questions.

If you don't mind, I have another question concerning listed items. I have two tabs open and I would like to run
winmergeu.exe -r <cureitem> other_curitem
How can I get other_curitem from the second tab listing?

I don't know how to do this with "open with" or with input().

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Assigning external programs to the Keyboard Funtion Keys

Post by highend »

How can I get other_curitem from the second tab listing?

Code: Select all

$otherPaneItem = get("Item", "i"); 
One of my scripts helped you out? Please donate via Paypal

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

Re: Assigning external programs to the Keyboard Funtion Keys

Post by admin »

I use this Portable File Associations to compare files with WinMerge. It compares the file on clipboard with the currently selected file:

Code: Select all

|"WinMerge (clip / cur)" *;\>"C:\Program Files (x86)\WinMerge\WinMergeU.exe" "<clipboard>" "<curitem>"
If you like it add it here:
Tools | Customize File Associations...

click-click
Posts: 6
Joined: 04 Feb 2017 15:45

Re: Assigning external programs to the Keyboard Funtion Keys

Post by click-click »

Code: Select all

|"WinMerge (clip / cur)" *;\>"C:\Program Files (x86)\WinMerge\WinMergeU.exe" "<clipboard>" "<curitem>"
Isn't that the same as just running winmergeu.exe "<curitem>" "<clp>"?

Can you explain "WinMerge (clip / cur)" *;\>?
I don't see this syntax described anywhere in the script reference. I thought clip was a Windows command.

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

Re: Assigning external programs to the Keyboard Funtion Keys

Post by admin »

click-click wrote:

Code: Select all

|"WinMerge (clip / cur)" *;\>"C:\Program Files (x86)\WinMerge\WinMergeU.exe" "<clipboard>" "<curitem>"
Isn't that the same as just running winmergeu.exe "<curitem>" "<clp>"?

Can you explain "WinMerge (clip / cur)" *;\>?
I don't see this syntax described anywhere in the script reference. I thought clip was a Windows command.
Yes, it's indeed the same.

"WinMerge (clip / cur)" is just the caption shown in the Open With menu.

*;\ means match all files and all folders.

Post Reply