Page 1 of 1

Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 11:20
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.

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 12:16
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...

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 14:57
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?

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 15:07
by highend
Probably hardcoded to all the functions it already has (executing files/opening non-executables, folders...)

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 16:20
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?

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 17:09
by highend
Single quotes -> No variable resolving -> <curitem> = literal "<curitem>"

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 23:03
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?

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 05 Feb 2017 23:09
by highend

Code: Select all

input()
is the necessary scripting command

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 10:43
by admin
Tip: The "Open With" category in User-Defined Commands is meant to do exactly this.

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 14:07
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().

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 14:10
by highend
How can I get other_curitem from the second tab listing?

Code: Select all

$otherPaneItem = get("Item", "i"); 

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 14:22
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...

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 18:27
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.

Re: Assigning external programs to the Keyboard Funtion Keys

Posted: 06 Feb 2017 18:36
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.