F4MiniMenu - v0.95
A minimalistic clone of the F4Menu program for Total Commander (open selected files in editor(s)) just offering the basic functionality. Original F4Menu program by Shao Shanny - www [.] shanny [.] com [.] cn (website seems to be offline, see TC forum links below)
If you have any questions or suggestions do feel free to post them at the F4MiniMenu TC Forum thread.
F4 is the shortcut key used in Total Commander - a file manager for Windows - for opening selected files in a pre-defined editor. In TC only one program can be assigned to F4 making it impossible to define or select other editors for different file types. Several tools have been made to solve this problem, these include:
- Open File shell for TC
- Total Commander Edit Redirector
- and of course F4Menu - TC Forum thread
While the original F4Menu has quite a few options, this minimalistic "clone" only has the basic functionality: opening multiple file types in various editors. There are various methods to open selected files: regular, "Drag & Drop", Filelist or by making use of a cmdline option.
As of v0.95 you can make use a helper script to use F4MiniMenu settings as the "internal editor" defined in Total Commander and use so called DocumentTemplates for creating new files. See F4TCIE.
First come, first serve
F4MiniMenu will open a file in the first editor it can find a match for based on the extension. If it can not find a match it will open the file(s) in the default editor. The default editor is the first editor listed in the Configure editors window. If you look in the configuration XML it will be the first editor there. If you want to open the file(s) in another program you can use the Foreground menu option. See screenshot below.
You can add or modify editors via the tray menu or by bringing up the Foreground menu. You can use %Commander_Path% in the paths to the editors and icons.
In principle you can run F4Menu and F4MiniMenu side by side as long as you do not use conflicting keyboard shortcuts. If you use same hotkey setup, F4MiniMenu will take precedence. You can set the F4MiniMenu shortcuts via the tray menu, right click, Settings option.
In general: be careful opening with opening large numbers of files at once, programs can crash and your computer could become unstable requiring a reboot.
Do not edit the "F4MiniMenu.xml" or "F4MiniMenu.ini" settings file while the script is running, any changes you make will be overwritten when the script exits. As of v0.61 a backup is made at startup and saved as "F4MiniMenu.xml.bak" or "F4MiniMenu.ini.bak"
Use at your own risk.
Many programs support Drag & Drop, but not all programs will respond well to the Drag & Drop method used in this script, so if it does not seem to work with a particular program, try the Normal method.
Some programs allow you to open files which are listed in a (temporary) file. In Total Commander you can use something similar in the Button bar and in the Start Menu where you can use the %L parameter to create a list file with the names of the selected files and directories, one file per line. F4MiniMenu can do the same. If you use this method a temporary file named $$f4mtmplist$$.m3u is created which is passed on to the target program.
Example Filelist usage:
Program: C:\Program Files\XnView\xnview.exe Parameters: -filelist Method: 3 - Filelist
Result: Selected files will now be opened in the XnView browser.
In case you need to pass the selected files to the program on the command line (program.exe file1 file2 etc) you can use the cmdline method.
Examples cmdline usage:
Program: C:\Program Files\Meld\Meld.exe Method: 4 - cmdline
Result: Selected files will be opened in Meld (diff program) Discussion
Program: c:\tools\mp3wrap\mp3wrap.exe Parameters: ?output.mp3 Startdir: %p Method: 4 - cmdline
Result: Selected MP3 files will be merged into one larger MP3 file asking the user for a filename (output.mp3 would be default)
- The reason for the .m3u extension is simple: it enables playlist support for WinAmp: Select multiple music files and press the hotkey to play the selected files. If the temporary file didn't have the .m3u extension WinAmp wouldn't recognize it as a playlist.
- The temporary file $$f4mtmplist$$.m3u is not deleted directly after use to avoid problems with slow programs. It is deleted when F4MiniMenu starts or closes.
- AutoHotkey 1.1+ (Ansi or Unicode)
- Total Commander
Download the source as a ZIP from GitHub here https://github.com/hi5/F4MiniMenu/archive/master.zip and unpack. To start it simply run F4MiniMenu.ahk. You can now setup F4MiniMenu using the tray menu options for Settings and Configure editors.
Once you have setup your shortcuts you can also access Settings and Configure editors via the Foreground menu options by pressing the shortcut (press Esc+F4 by default). See screenshots below.
XML or INI - There are two versions:
- F4MiniMenu.ahk uses XML to store settings (F4MiniMenu.xml)
F4MiniMenui.ahk uses INI to store settings (F4MiniMenu.ini)If you want to store your settings in INI format (F4MiniMenu.ini) simply rename the (compiled) script so it ends with an i (letter i) so rename or copy F4MiniMenu.ahk to F4MiniMenui.ahk and start. That would work, but F4MMi.exe as well.
If you want to make use of your preferred editor(s) when the active panel is in an Archived file (ZIP panel) or FTP connection you can make use of a helper script called F4TCIE. If you are using the INI format to store your settings be sure to rename the script to end with an "i" (see 'XML or INI' above)
When F4MiniMenu sees the files you have selected are in an archive or in an FTP panel, it uses the default Total Commander Edit command. It will only use the first file if you had selected multiple files in the archive or FTP.
So we need to configure Total Commander to use F4TCIE.ahk like so:
TC, Configuration, Edit/View, Editor: drive:\path-to\F4TCIE.ahk "%1"
If for some reason it can't open the configuration file it will try to start the editor for the file type associated in Windows (so for txt -> notepad, for bmp,jpg -> MS Paint etc) - if there is no editor for the file type it would start notepad.exe as a final resort.
Reference: see also #13
F4TCIE can also make use of DocumentTemplates when creating New files in Total Commander using the shift+f4 shortcut.
More information can be found in the DocumentTemplates README
|%P||causes the source path to be inserted into the command line, including a backslash \ at the end.|
|%T||inserts the current target path.|
|%O||places the current filename without extension into the command line.|
|%E||places the current extension (without leading period) into the command line.|
|?||as the first parameter causes a Dialog box to be displayed before starting the program, containing the following parameters. You can change the parameters before starting the program. You can even prevent the program's execution.|
|%f41||placeholder to alter position of filenames on the command line. (see example below)|
Note: More %f4 fields may be added in the future.
F4MiniMenu starts programs as follows:
ProgramName.exe Parameters File(s) Startdir
But for some programs the parameter(s) - the additional command(s) you want to pass on to the program - have the come AFTER the File(s) so by using %f41 as a placeholder in the parameters field you can tell F4MiniMenu where to place the files on the "command line"
Program: pdftk.exe Parameters: %f41 burst
So the program now starts as pdftk.exe file.pdf burst (instead of pdftk.exe burst file.pdf)
General program settings
TODO - Known issues
- TOFIX: If you change the order of the editors first and then add a new one, the order is set back to the initial order.
2. INFO: Delay (in milliseconds) is only applicable to Drag & Drop method.
- INFO: Two options for delay (as of v0.9):
2.1 Drag & Drop delay gives program to start up before trying to drop the files - you may need to apply trail and error.
2.2 Open delay, pauses X ms to open next file.
- TODO: Change from standalone setup (as it currently is) to #include mode, which will make it easier to #include it in a "always" running AHK script.
- Open source - written in AutoHotkey
- Supports Drag & Drop (for AutoHotkey 1.1+ Ansi and Unicode)
- Supports Filelist method (Similar to %L in TC) as of v0.5
Used AHK Functions & Libraries
- Class LV_Rows by Pulover - as of v0.6
- XA Save / Load Arrays to/from XML Functions - trueski - using a 'fixed' version as forum post is messed up
- DropFilesA - SKAN including Unicode version nimda
- Based on original idea from F4Menu by Shao Shanny - Backup links for the program can be found on the Total Commander forum
- 20170710 - v0.95 Added F4TCIE and introduced DocumentTemplates. #13 https://github.com/hi5/F4MiniMenu/issues/13
New icon :-)
- 20170607 - v0.94c Minor fix to empty file and quoted startdir variables in GetInput(). Fix for %ComSpec% in Editor names.
- 20170106 - v0.94b Minor fix to ensure Commander_Path is not empty
- 20170105 - v0.94a Minor fix for launching via Drag&Drop (no longer worked correctly/reliably in v0.94)
- 20161231 - v0.94
a) Added 4th method: cmdline -> program.exe file1 file2 file3 #14 https://github.com/hi5/F4MiniMenu/issues/14
b) Accept TC Fields %P %T %O %E and ? in Parameters and Startdir. Introduced %f41. #15 https://github.com/hi5/F4MiniMenu/issues/15
c) Build foreground menu only once vs delete/recreate (updating menu only after editing editors). Refactored menu code.
d) Now use %TEMP%$$f4mtmplist$$.m3u instead of ScriptFolder - requested by Ovg
e) Fixed hotkeys - #12 https://github.com/hi5/F4MiniMenu/issues/12
f) You can now specify an Icon and Menu name when you configure an Editor. #17 https://github.com/hi5/F4MiniMenu/issues/17
g) %Commander_Path% now accepted in Editor and Icon paths. h) Removed F4MiniMenui.ahk - to use INI simply rename/copy the (compiled) script to end with "i".
- 20161023 - v0.93 OpenFile: add WinWait before WinActivate, merge request @nameanyone #10 https://github.com/hi5/F4MiniMenu/issues/10
- 20160618 - v0.92 Fix error checking on startup in case script is compiled - HT Ovg
- 20160618 - v0.91 Fix for INI Editors include (save to INI not XML when making backup). Refinement of regular expression for wildcards - HT Ovg
- 20160618 - v0.9 Added support for wildcards (? and *) in extensions #6 https://github.com/hi5/F4MiniMenu/issues/6. Added open delay (delay in ms between opening files)
- 20160617 - v0.83 Adding specific #include path for lib files to avoid possible error for portable users when compiling. HT Ovg
- 20151104 - v0.82 Further refinement of confusing error message at very first startup (missing configuration XML) - now also checks if BAK is present.
- 20151103 - v0.81 Fixed confusing error message at very first startup (missing configuration XML)
- 20141107 - v0.8 Added F4 functions to Lister (grabbing the filename from the Window title) and the search results in the Find Files dialog. Comment: if you use the Esc & Key as Foreground menu option it will fail as pressing Esc will close Lister and the Find Files dialog. The Winkey & Key combination does work - the menu will appear at the top of the window.
- 20140806 - v0.7 replaced Loop, object.MaxIndex() with proper for-loop to parse each key-value pair in the MatchList object; Added &letter to foreground menu options (program names)
- 20130731 - v0.61 added rudimentary backup & safety feature in case of a faulty/missing settings XML
- 20130701 - v0.6 a) Class LV_Rows by Pulover replaces LV_MoveRow(). This resolves the problem with the listview not updating icons while moving the editors in the settings Gui; b) Added Unicode support for drag & drop method so F4MiniMenu should now be compatible with both Ansi and Unicode versions of AutoHotkey.
- 20130607 - v0.51 Check if selected file(s) are archived, if so bypass F4MiniMenu all together and use internal TC Edit command to open file, this will only use the file under the cursor, not all selected files.
- 20130330 - v0.5 a) Process entire file list first and open per program; b) Introduced Filelist method; c) Removed "Open Mode".
- 20121117 - v0.4 Configuration GUIs, tray menu. First editor now considered default editor.
- 20121111 - v0.3 Added menu for "foreground" feature - open all selected files with specific editor (its behaviour may change in future).
- 20121108 - v0.2 Added 0 (zero) entry in XML as default editor.
- 20121101 - v0.1 Initial very basic version.