From be1fae6f6d0dd753dca3231c66dbc356dd9e9cc8 Mon Sep 17 00:00:00 2001 From: hi5 Date: Mon, 30 Oct 2023 19:26:34 +0100 Subject: [PATCH] v1.2 - main fix: no longer require full path which was inadvertently introduced in v1.1 --- F4MiniMenu.ahk | 170 +++++++++++++++++++++++++++++------- F4TCIE.ahk | 33 ++++--- changelog.md | 21 ++++- inc/HelperFunctions.ahk | 24 +++--- inc/Settings.ahk | 185 +++++++++++++++++++++------------------- lib/QDir.ahk | 2 + lib/tc.ahk | 87 +++++++++++++++++++ readme.md | 112 +++++++++++++++--------- 8 files changed, 446 insertions(+), 188 deletions(-) create mode 100644 lib/tc.ahk diff --git a/F4MiniMenu.ahk b/F4MiniMenu.ahk index ac238fc..91755c0 100644 --- a/F4MiniMenu.ahk +++ b/F4MiniMenu.ahk @@ -1,7 +1,7 @@ /* Script : F4MiniMenu.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode) -Version : v1.1 +Version : v1.2 Author : hi5 Last update : 02 April 2023 Purpose : Minimalistic clone of the F4 Menu program for Total Commander (open selected files in editor(s)) @@ -19,10 +19,10 @@ SetWorkingDir, %A_ScriptDir% SetTitleMatchMode, 2 ; Setup variables, menu, hotkeys etc -F4Version:="v1.1" +F4Version:="v1.2" ; -;@Ahk2Exe-SetFileVersion 1.1 +;@Ahk2Exe-SetFileVersion 1.2 ;@Ahk2Exe-SetDescription F4MiniMenu: Open files from TC ;@Ahk2Exe-SetCopyright MIT License - (c) https://github.com/hi5 ; @@ -153,6 +153,7 @@ If (MatchList.settings.XYPlorer <> "") If (MatchList.settings.QDir <> "") { GroupAdd, TCF4Windows, ahk_exe Q-Dir.exe + GroupAdd, TCF4Windows, ahk_exe Q-Dir_x64.exe } ; /Add other file managers if any @@ -273,7 +274,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1") If WinActive("ahk_class TTOTAL_CMD ahk_exe TOTALCMD.EXE") or WinActive("ahk_class TTOTAL_CMD ahk_exe TOTALCMD64.EXE") { IfNotExist, %check% ; additional check, if the file is from an archive it won't exist - { ; therefore we resort to the internal TC Edit command - added for v0.51 + { ; therefore we resort to the internal TC Edit command - added for v0.51 SendMessage 1075, 904, 0, , ahk_class TTOTAL_CMD ; Edit (Notepad) Return } @@ -282,7 +283,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1") If MatchList.settings.DoubleCommander and DoubleCommander_Active() { IfNotExist, %check% ; additional check, if the file is from an archive it won't exist - { ; therefore we resort to sending enter, now user can choose what to do (close or edit using default program) + { ; therefore we resort to sending enter, now user can choose what to do (close or edit using default program) Send {enter} Return } @@ -291,7 +292,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1") If MatchList.settings.Explorer and Explorer_Active() { IfNotExist, %check% ; additional check, if the file is from an archive it won't exist - { ; don't allow it and return for Explorer + { ; don't allow it and return for Explorer MsgBox, 16, F4MiniMenu, You can not edit files from Archives when using Explorer. Return } @@ -394,6 +395,7 @@ GetExt(Files) MatchList.Temp["SelectedExtensions"]:=Trim(Ext,"|") } +; Process other applications and windows first (find files, lister) ; Get a list of selected files using internal TC commands (see totalcmd.inc for references) GetFiles() { @@ -420,26 +422,26 @@ GetFiles() Return Files } - If MatchList.settings.DoubleCommander and DoubleCommander_Active() - { - Files:=DoubleCommander_GetSelection() - MatchList.Temp["Files"]:=Files - Return Files - } + If MatchList.settings.DoubleCommander and DoubleCommander_Active() + { + Files:=DoubleCommander_GetSelection() + MatchList.Temp["Files"]:=Files + Return Files + } - If MatchList.settings.XYPlorer and XYPlorer_Active() - { - Files:=XYPlorer_GetSelection() - MatchList.Temp["Files"]:=Files - Return Files - } + If MatchList.settings.XYPlorer and XYPlorer_Active() + { + Files:=XYPlorer_GetSelection() + MatchList.Temp["Files"]:=Files + Return Files + } - If MatchList.settings.QDir and QDir_Active() - { - Files:=QDir_GetSelection() - MatchList.Temp["Files"]:=Files - Return Files - } + If MatchList.settings.QDir and QDir_Active() + { + Files:=QDir_GetSelection() + MatchList.Temp["Files"]:=Files + Return Files + } If WinActive("ahk_class TLister") { @@ -448,9 +450,10 @@ GetFiles() Return Files } - If WinActive("ahk_class TFindFile") + If WinActive("ahk_class TFindFile") ; class names may change between versions, below for TC11 { - ControlGet, Files, Choice,, TWidthListBox1, ahk_class TFindFile + ; ControlGet, Files, Choice,, TWidthListBox1, ahk_class TFindFile; for TC10 + ControlGet, Files, Choice,, TMyListBox2, ahk_class TFindFile If (ErrorLevel = 1) or (Files = "") ControlGet, Files, Choice,, LCLListbox2, ahk_class TFindFile IfNotInString, Files,[ ; make sure you haven't selected a directory or the first line @@ -483,9 +486,9 @@ OpenFile(Editor,open,MaxWinWaitSec=2) If (func = "FileList") { ; if GetInput() was cancelled don't process windowmode below - result:=Normal(Editor.Exe,open,Editor.Delay,Editor.Parameters,Editor.StartDir) + result:=Normal(Editor.Exe,open,Editor.Delay,Editor.Parameters,Editor.StartDir) } - Else If IsFunc(func) ; takes care of drag & drop; cmdline + Else If IsFunc(func) ; takes care of normal, drag & drop, and cmdline { ; if GetInput() was cancelled don't process windowmode below result:=%func%(Editor.Exe,open,Editor.Delay,Editor.Parameters,Editor.StartDir) @@ -534,7 +537,9 @@ Normal(program,file,delay,parameters,startdir) startdir:=GetPath(startdir) if (file = "") Try + { Run, %program% %parameters%, %startdir% + } Catch { ;program:=GetTCCommander_Path(MatchList[1].Exe) @@ -545,7 +550,12 @@ Normal(program,file,delay,parameters,startdir) } else Try - Run, %program% %parameters% "%file%", %startdir% + { + if (file <> "") + Run, %program% %parameters% "%file%", %startdir% + else + Run, %program% %parameters%, %startdir% + } Catch { ;program:=GetTCCommander_Path(MatchList[1].Exe) @@ -630,6 +640,17 @@ GetInput(byref parameters, byref file, byref startdir, byref execute, program) parameters:=StrReplace(parameters,"%t",GetTCFields("%t")) if InStr(parameters,"%o") parameters:=StrReplace(parameters,"%o",GetTCFields("%o",file)) + if InStr(parameters,"%n") + parameters:=StrReplace(parameters,"%o",GetTCFields("%n",file)) + if InStr(parameters,"%m") + parameters:=StrReplace(parameters,"%o",GetTCFields("%m",file)) + if InStr(parameters,"%$date") + { + DateTimeObject:=GetTCFields(parameters) + parameters:=StrReplace(parameters,DateTimeObject[1],DateTimeObject[2]) + DateTimeObject:="" + } + if InStr(parameters,"%e") parameters:=StrReplace(parameters,"%e",GetTCFields("%e",file)) ; %f4? placeholders for optional parameters: @@ -640,6 +661,7 @@ GetInput(byref parameters, byref file, byref startdir, byref execute, program) parameters:=StrReplace(parameters, "%f41", file) file:="" } + if InStr(startdir,"%p") startdir:=StrReplace(startdir,"%p",GetTCFields("%p")) if InStr(startdir,"%t") @@ -706,7 +728,6 @@ GetInput(byref parameters, byref file, byref startdir, byref execute, program) Gui, AskInput:Destroy execute:=1 Return - } CheckFile(list,file) @@ -727,8 +748,22 @@ GetTCFields(opt,file="") { ; %P causes the source path to be inserted into the command line, including a backslash (\) at the end. ; %T inserts the current target path. Especially useful for packers. + + ; first we deal with non TC + + if MatchList.settings.Explorer or MatchList.settings.XYPlorer or MatchList.settings.QDir or MatchList.settings.Everything + { + if (opt = "%p") or (opt = "%t") + { + SplitPath, file, , OutDir ; panel + Return OutDir + } + } + + ; SP = Source Path, TP = Target Path if (opt = "%p") or (opt = "%t") { + /* ; cm_CopySrcPathToClip=2029 ; Copy source path to clipboard ; cm_CopyTrgPathToClip=2030 ; Copy target path to clipboard ; % (panel = "%p") ? "source" : "target" @@ -737,9 +772,19 @@ GetTCFields(opt,file="") SendMessage 1075, % (opt = "%p") ? 2029 : 2030, 0, , ahk_class TTOTAL_CMD panel:=Clipboard "\" Clipboard:=ClipSaveAll + */ + panel:=TC_SendData((opt = "%p") ? "SP" : "TP") Return panel } + ; SN = Source Name Caret, TN = Target Name Caret + if (opt = "%n") or (opt = "%m") + { + NameCaret:=TC_SendData((opt = "%n") ? "SN" : "TN") + Return NameCaret + } + + ; %O places the current filename without extension into the command line. ; %E places the current extension (without leading period) into the command line. if (opt = "%o") or (opt = "%e") @@ -762,7 +807,71 @@ GetTCFields(opt,file="") } Return % (opt = "%o") ? filenames : fileext } + + if InStr(opt, "%$date") + { + + /* TC HELP + %$DATE% Inserts the 24 hour date and time in the form YYYYMMDDhhmmss -> A_Now in AutoHotkey + + %$DATE:placeholders% + Inserts the date in the form specified by placeholders. + Same as in multi-rename tool: -> AHK + y Paste year in 2 digit form -> yy + Y Paste year in 4 digit form -> yyyy + M Paste month, always 2 digit -> MM + D Paste day, always 2 digit -> dd + h Paste hours, always in 24 hour 2 digit format (0-23) -> H + H Paste hours, always in 12 hour 2 digit format (1-12) -> hh + i1 same but 1 character a/p only -> t + i am/pm indicator in English -> tt + m Paste minutes, always in 2 digit format -> mm + s Paste seconds, always in 2 digit format -> ss + any non-alpha character like a dot or dash will be added directly + + F4MM addition: |value|timeunit + + */ + + DateTimeObject:=[] + + ; output entire string, output1 time formatting options + RegExMatch(opt,"Ui)%\$date:*([^%]*)%",output) + + if (output = "%$DATE%") + { + FormatTime, DateTime, , %A_Now% + DateTimeObject[1]:="%$DATE%" + DateTimeObject[2]:=DateTime + return % DateTimeObject + } + else ; output1 -> we have placeholders + { + OutputData:=StrSplit(output1,"|") + ; 1 placeholder, 2 value, 3 time units + ; the order in which we process the format is important (y before Y, h-zzzzz-H, i1 before i) + OutputData[1]:=RegExReplace(OutputData[1],"y","yy") + OutputData[1]:=RegExReplace(OutputData[1],"Y","yyyy") + OutputData[1]:=RegExReplace(OutputData[1],"M","MM") + OutputData[1]:=RegExReplace(OutputData[1],"D","dd") + OutputData[1]:=RegExReplace(OutputData[1],"h","zzzzz") ; we need to swap lower case h for temp char z + OutputData[1]:=RegExReplace(OutputData[1],"H","hh") ; we we can safely process H hh conversion + OutputData[1]:=RegExReplace(OutputData[1],"zzzzz","H") ; and now use char z for h->H conversion + OutputData[1]:=RegExReplace(OutputData[1],"i1","t") + OutputData[1]:=RegExReplace(OutputData[1],"i","tt") + OutputData[1]:=RegExReplace(OutputData[1],"m","mm") + OutputData[1]:=RegExReplace(OutputData[1],"s","ss") + DateTimeFormat:=OutputData[1] + + FormatTime, DateTime,, yyyyMMddHHmmss + EnvAdd, DateTime, % OutputData[2], % OutputData[3] ; do math if any + FormatTime, DateTime, %DateTime%, %DateTimeFormat% ; format the time + DateTimeObject[1]:=output + DateTimeObject[2]:=DateTime + return % DateTimeObject + } + } } SetHotkeys: @@ -1011,3 +1120,4 @@ Return #include %A_ScriptDir%\lib\DropFiles.ahk #include %A_ScriptDir%\lib\GetPos.ahk #include %A_ScriptDir%\lib\dpi.ahk +#include %A_ScriptDir%\lib\tc.ahk ; wm_copydata diff --git a/F4TCIE.ahk b/F4TCIE.ahk index f688909..ee4814c 100644 --- a/F4TCIE.ahk +++ b/F4TCIE.ahk @@ -1,9 +1,9 @@ /* Script : F4TCIE.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode) -Version : 0.5 +Version : 0.6 Author : hi5 -Last update : 12 November 2022 +Last update : 30 October 2023 Purpose : Helper script for F4MiniMenu program to allow internal editor to function now you can edit files from within Archives and FTP (and have TC update/upload them) Notes : It will always use the "normal" method to open programs, so the "drag & drop", "filelist" @@ -28,7 +28,7 @@ Templates : Create a DocumentTemplates\ folder and place files for each templa ; ;@Ahk2Exe-SetDescription F4MiniMenu (IE): Open files from TC -;@Ahk2Exe-SetFileVersion 1.1 +;@Ahk2Exe-SetFileVersion 1.2 ;@Ahk2Exe-SetCopyright MIT License - (c) https://github.com/hi5 ; @@ -49,9 +49,9 @@ If Error { MsgBox, 16, F4MiniMenu/F4TCIE, Couldn't load configuration file (%F4ConfigFile%), closing script and starting default Windows editor.`n`nMay not work if there is no "Edit" defined for this filetype:`n`n%OutExtension%`n`nNote: do check if F4MiniMenu/F4TCIE have the same naming convention (for INI both program names have to end with an "i")`nSee "XML or INI" https://github.com/hi5/F4MiniMenu/blob/master/readme.md Try - Run edit %file% ; run Windows editor for this filetype + Run edit "%file%" ; run Windows editor for this filetype Catch - Run notepad %file% ; alas no type defined so run notepad as a last resort + Run %A_WinDir%\notepad.exe "%file%" ; alas no type defined so run notepad as a last resort ExitApp } @@ -66,7 +66,7 @@ for k, v in MatchList continue if (v.ext = "") ; reported by Ovg if EXT is empty it would not launch the default editor continue - If RegExMatch(OutExtension,RegExExtensions(v.ext)) ; Open in defined program - v0.9 allow for wildcards + if RegExMatch(OutExtension,RegExExtensions(v.ext)) ; Open in defined program - v0.9 allow for wildcards { ;editor:=GetTCCommander_Path(v.exe) editor:=GetPath(v.exe) @@ -79,24 +79,34 @@ for k, v in MatchList FileCopy, %A_ScriptDir%\DocumentTemplates\template.%OutExtension%, %file%, 1 } } - If editor + if editor { Sleep % v.delay Try - Run %editor% %file% + { + Run "%editor%" "%file%" + Sleep 100 ; added explicit Exit as compiled version sometimes kept running 30/10/2023 + ExitApp + } Catch { - Run % GetPath(matchlist[1].exe) A_Space file + editor:=GetPath(matchlist[1].exe) + Run "%editor%" "%file%" ; OSDTIP_Pop(MainText, SubText, TimeOut, Options, FontName, Transparency) OSDTIP_Pop("F4MiniMenu/F4TCIE", "Defined editor/program not found`nReverting to default editor", -750,"W230 H80 U1") - } + Sleep 100 ; added explicit Exit as compiled version sometimes kept running 30/10/2023 + ExitApp + } } ExitApp ; we only have one file to process so we're done } } ; We couldn't find a defined Editor so launch the default Editor [1] -Run % GetPath(matchlist[1].exe) A_Space file +editor:=GetPath(matchlist[1].exe) +Run "%editor%" "%file%" +Sleep 100 ; added explicit Exit as compiled version sometimes kept running 30/10/2023 +ExitApp ; shared with F4MM #include %A_ScriptDir%\inc\HelperFunctions.ahk @@ -104,4 +114,3 @@ Run % GetPath(matchlist[1].exe) A_Space file ; just for loading the Matchlist object, we don't need all the rest #include %A_ScriptDir%\lib\xa.ahk #include %A_ScriptDir%\lib\iob.ahk - diff --git a/changelog.md b/changelog.md index 9c168a3..274a2ae 100644 --- a/changelog.md +++ b/changelog.md @@ -1,15 +1,28 @@ ## Changelog +* 20231121 - v1.2 + a) Updated class name for Find Results control class (TMyListBox2, 32bit) for TC11 + b) Added: Help MsgBox-es in Settings Gui now Task Modal (32+8192=8224) + c) Added: Settings label to Gui to better handle closing the Gui https://github.com/hi5/F4MiniMenu/issues/24#issuecomment-1573127847 + d) Added: GuiEscape for Add/Modify editors dialog to allow Esc to exit (next to Alt+c) https://github.com/hi5/F4MiniMenu/issues/24#issuecomment-1573127847 + e) Fix: no longer require full path for programs in PATH e.g. `write.exe` v `c:\windows\write.exe`, bug introduced in v1.1 due to GetFullPathName() https://github.com/hi5/F4MiniMenu/issues/24#issuecomment-1573127847 + f) Fix: use SplitPath for `%p` parameter when not using TC https://github.com/hi5/F4MiniMenu/issues/24#issuecomment-1573127847 + g) Change: `%p` and `%t` now use wm_copydata + h) New: `%N` and `%M` to place filename under the cursor into the command line (source and target directory) using wm_copydata + i) New: Added support for `%$DATE%`, `%$DATE:YMD%` + offset calculations via `%$DATE:YMD|value|timeunits%` + j) Fix: F4TCIE quote file path for `%file%` to resolve paths\files with spaces + k) Fix: F4TCIE `Run notepad` changed to `Run %A_WinDir%\notepad.exe` to avoid any potential path issues. Added ExitApp after Run command + * 20230402 - v1.1 a) Fix: TRY to catch all empty hotkeys to avoid errors at startup - b) Change: Double click on an "editor" in Configure Editors listview now opens modify window + b) Change: Double click on an "editor" in Configure Editors listview now opens modify window c) Change: Settings - replace Radio controls for Esc/Win with DropDownLists (not thoroughly tested) d) Fix: WinMin/Hide/Maximize and Sleep function should work better (or again) e) Fix: additional check to prevent Modify Gui throwing "The same variable cannot be used for more than one control" error; modify window now always on top of editors window (); sysmenu removed f) New: TRY, catch -> revert to standard editor if defined editor can not be found, show notification using OSDTIP_Pop() for both F4MiniMenu and F4TCIE - g) New: support %windir%, %A_ScriptDir% and other path variables (see list "Path variables" in readme.md) https://github.com/hi5/F4MiniMenu/issues/25 - h) New: Filtered foreground Menu - setting to launch program directly if only one program is found https://github.com/hi5/F4MiniMenu/issues/26 - i) New: Global setting MaxWinWaitSec to prevent stalling F4MM + g) New: support `%windir%`, `%A_ScriptDir%` and other path variables (see list "Path variables" in readme.md) https://github.com/hi5/F4MiniMenu/issues/25 + h) New: Filtered foreground Menu - setting to launch program directly if only one program is found https://github.com/hi5/F4MiniMenu/issues/26 + i) New: Global setting MaxWinWaitSec to prevent stalling F4MM j) Fix: INI when reading a global setting as "Error" set as empty (lib\iob.ahk) * 20220528 - v1.0 a) Fix: "Start Total Commander if not running" feature #23 https://github.com/hi5/F4MiniMenu/issues/23 diff --git a/inc/HelperFunctions.ahk b/inc/HelperFunctions.ahk index 4535949..accf101 100644 --- a/inc/HelperFunctions.ahk +++ b/inc/HelperFunctions.ahk @@ -1,19 +1,21 @@ ; used in F4MiniMenu and F4TCIE -GetPath(editor) +GetPath(path) { global MyComSpec,Commander_Path,MyProgramFiles,MyProgramFilesx86,MyProgramW6432 - if !InStr(editor,"%") - Return GetFullPathName(editor) + ; path:=StrReplace(path,"%ComSpec%",MyComSpec) + if !InStr(path,"\") ; for programs in path environment e.g. wordpad, write + Return path + if !InStr(path,"%") ; no special treatment required + Return GetFullPathName(path) Loop, parse, % "Commander_Path,A_ScriptDir,A_ComputerName,A_UserName,A_WinDir,A_ProgramFiles,ProgramFiles,A_AppData,A_AppDataCommon,A_Desktop,A_DesktopCommon,A_StartMenu,A_StartMenuCommon,A_Programs,A_ProgramsCommon,A_Startup,A_StartupCommon,A_MyDocuments", CSV - editor:=StrReplace(editor,"%" A_LoopField "%",%A_LoopField%) - ; special cases - editor:=StrReplace(editor,"%WinDir%",A_WinDir) - editor:=StrReplace(editor,"%ComSpec%",MyComSpec) - editor:=StrReplace(editor,"%ProgramFiles%",MyProgramFiles) - editor:=StrReplace(editor,"%ProgramFiles(x86)%",MyProgramFilesx86) - editor:=StrReplace(editor,"%ProgramW6432%",MyProgramW6432) - Return GetFullPathName(editor) + path:=StrReplace(path,"%" A_LoopField "%",%A_LoopField%) + ; special cases + path:=StrReplace(path,"%WinDir%",A_WinDir) + path:=StrReplace(path,"%ProgramFiles%",MyProgramFiles) + path:=StrReplace(path,"%ProgramFiles(x86)%",MyProgramFilesx86) + path:=StrReplace(path,"%ProgramW6432%",MyProgramW6432) + Return GetFullPathName(path) } ; get absolute path from relative path diff --git a/inc/Settings.ahk b/inc/Settings.ahk index 9ca10be..ac06a14 100644 --- a/inc/Settings.ahk +++ b/inc/Settings.ahk @@ -29,29 +29,29 @@ HotKeyState:="Off" Gosub, SetHotkeys ; Gui for general program settings -Gui, +OwnDialogs -Gui, font, % dpi("s8") -Gui, Add, GroupBox, % dpi("x16 y7 w540 h70"), Menu -Gui, Add, Text, % dpi("x25 y25 w309 h16"), &Selection menu appears -Gui, Add, DropDownList, % dpi("x328 y20 w219 h25 r4 Choose" MatchList.settings.MenuPos " vMenuPos AltSubmit"), 1 - At Mouse cursor|2 - Centered in window|3 - Right next to current file|4 - Docked next to current file (opposite panel) -Gui, Add, Text, % dpi("x25 yp+35 w309 h16"), &Accelerator key for full menu (for use in filtered menu, 1 char.) -Gui, Add, Edit, % dpi("x328 yp-5 w30 h21 vFullMenu"), % MatchList.settings.FullMenu ; % -Gui, Add, Text, % dpi("x365 yp+5 w70 h16"), If one result: -Gui, Add, DropDownList, % dpi("x430 yp-5 w117 h25 r2 Choose" MatchList.settings.FilteredMenuAutoEdit " vFilteredMenuAutoEdit AltSubmit"), 1 - Show menu|2 - Edit directly - -Gui, Add, GroupBox, % dpi("x16 yp+40 w260 h45"), Files -Gui, Add, Text, % dpi("x25 yp+20 w209 h16"), &Maximum number of files to be opened -Gui, Add, Edit, % dpi("x227 yp-5 w40 h21 Number vMaxFiles"), % MatchList.settings.Maxfiles ; % - -Gui, Add, GroupBox, % dpi("x280 yp-15 w276 h45"), WinWait -Gui, Add, Text, % dpi("x289 yp+20 w209 h16"), &Seconds (max) to wait for program window -Gui, Add, Edit, % dpi("x507 yp-5 w40 h21") -Gui, Add, UpDown, vMaxWinWaitSec Range2-10, % MatchList.Settings.MaxWinWaitSec ; % - - -Gui, Add, GroupBox, % dpi("x16 yp+40 w540 h70"), Total Commander -Gui, Add, DropDownList, % dpi("x25 yp+15 w240 h25 R3 Choose" MatchList.settings.TCStart " vTCStart AltSubmit"), 1 - Do not start TC (default)|2 - Start TC if not Running (set TC Path)|3 - Always start TC (set TC Path) -Gui, Add, Text, % dpi("xp+250 yp+5 w50 h16"), TC Path +Gui, Settings: +OwnDialogs +Gui, Settings: font, % dpi("s8") +Gui, Settings: Add, GroupBox, % dpi("x16 y7 w540 h70"), Menu +Gui, Settings: Add, Text, % dpi("x25 y25 w309 h16"), &Selection menu appears (TC only) +Gui, Settings: Add, DropDownList, % dpi("x328 y20 w219 h25 r4 Choose" MatchList.settings.MenuPos " vMenuPos AltSubmit"), 1 - At Mouse cursor|2 - Centered in window|3 - Right next to current file|4 - Docked next to current file (opposite panel) +Gui, Settings: Add, Text, % dpi("x25 yp+35 w309 h16"), &Accelerator key for full menu (for use in filtered menu, 1 char.) +Gui, Settings: Add, Edit, % dpi("x328 yp-5 w30 h21 vFullMenu"), % MatchList.settings.FullMenu ; % +Gui, Settings: Add, Text, % dpi("x365 yp+5 w70 h16"), If one result: +Gui, Settings: Add, DropDownList, % dpi("x430 yp-5 w117 h25 r2 Choose" MatchList.settings.FilteredMenuAutoEdit " vFilteredMenuAutoEdit AltSubmit"), 1 - Show menu|2 - Edit directly + +Gui, Settings: Add, GroupBox, % dpi("x16 yp+40 w260 h45"), Files +Gui, Settings: Add, Text, % dpi("x25 yp+20 w209 h16"), &Maximum number of files to be opened +Gui, Settings: Add, Edit, % dpi("x227 yp-5 w40 h21 Number vMaxFiles"), % MatchList.settings.Maxfiles ; % + +Gui, Settings: Add, GroupBox, % dpi("x280 yp-15 w276 h45"), WinWait +Gui, Settings: Add, Text, % dpi("x289 yp+20 w209 h16"), &Seconds (max) to wait for program window +Gui, Settings: Add, Edit, % dpi("x507 yp-5 w40 h21") +Gui, Settings: Add, UpDown, vMaxWinWaitSec Range2-10, % MatchList.Settings.MaxWinWaitSec ; % + + +Gui, Settings: Add, GroupBox, % dpi("x16 yp+40 w540 h70"), Total Commander +Gui, Settings: Add, DropDownList, % dpi("x25 yp+15 w240 h25 R3 Choose" MatchList.settings.TCStart " vTCStart AltSubmit"), 1 - Do not start TC (default)|2 - Start TC if not Running (set TC Path)|3 - Always start TC (set TC Path) +Gui, Settings: Add, Text, % dpi("xp+250 yp+5 w50 h16"), TC Path If !FileExist(MatchList.settings.TCPath) { RegRead TCPath, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, InstallDir @@ -60,26 +60,27 @@ If !FileExist(MatchList.settings.TCPath) MatchList["settings","TCPath"]:=TCPath TCPath:="" } -Gui, Add, Edit , % dpi("xp+53 yp-5 w180 h21 vTCPath"), % MatchList.settings.TCPath ; % -Gui, Add, Button, % dpi("xp+187 yp w30 h20 gSelectExe"), >> +Gui, Settings: Add, Edit , % dpi("xp+53 yp-5 w180 h21 vTCPath"), % MatchList.settings.TCPath ; % +Gui, Settings: Add, Button, % dpi("xp+187 yp w30 h20 gSelectExe"), >> Checked:=MatchList.settings.F4MMCloseAll -Gui, Add, Checkbox, % dpi("x25 yp+30 w250 h16 Checked" checked " vF4MMCloseAll"), Close F4MM when all copies of TC close +Gui, Settings: Add, Checkbox, % dpi("x25 yp+30 w250 h16 Checked" checked " vF4MMCloseAll"), Close F4MM when all copies of TC close Checked:=MatchList.settings.F4MMClosePID -Gui, Add, Checkbox, % dpi("xp+250 yp w250 h16 Checked" checked " vF4MMClosePID"), Close F4MM when TC closes started by F4MM -Gui, Font, % dpi("cGreen") -Gui, Add, Text, % dpi("xp+250 yp gFMMCloseHelpText"), (?) -Gui, Font, % dpi("cBlack") -Gui, Font, ; needed as theme is stripped from control @ https://www.autohotkey.com/boards/viewtopic.php?p=399355#p399355 -Gui, Font, % dpi("s8") -Gui, Add, GroupBox, % dpi("x16 yp+35 w395 h120"), Hotkeys - -Gui, Add, Text, % dpi("x25 yp+25 w150 h16"), &Background mode (direct) -;Gui, Add, Radio, % dpi("xp+130 yp w45 h16 vBEsc"), Esc -;Gui, Add, Radio, % dpi("xp+45 yp w45 h16 vBWin"), Win -Gui, Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vBMod"), |Esc|Win +Gui, Settings: Add, Checkbox, % dpi("xp+250 yp w250 h16 Checked" checked " vF4MMClosePID"), Close F4MM when TC closes started by F4MM +Gui, Settings: Font, % dpi("cGreen") +Gui, Settings: Add, Text, % dpi("xp+250 yp gFMMCloseHelpText"), (?) +Gui, Settings: Font, % dpi("cBlack") +Gui, Settings: Font, ; needed as theme is stripped from control @ https://www.autohotkey.com/boards/viewtopic.php?p=399355#p399355 +Gui, Settings: Font, % dpi("s8") +Gui, Settings: Add, GroupBox, % dpi("x16 yp+35 w395 h120"), Hotkeys + +Gui, Settings: Add, Text, % dpi("x25 yp+25 w150 h16"), &Background mode (direct) +;Gui, Settings: Add, Radio, % dpi("xp+130 yp w45 h16 vBEsc"), Esc +;Gui, Settings: Add, Radio, % dpi("xp+45 yp w45 h16 vBWin"), Win +Gui, Settings: Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vBMod"), |Esc|Win ; Always annoying to work around Hotkey control limit, use boxes for Win & Esc keys +Gui, Settings: Default If InStr(BGHKey,"#") { StringReplace, BGHKey, BGHKey, #, , All @@ -94,12 +95,14 @@ If InStr(BGHKey,"Esc &") GuiControl, Choose, BMod, 3 } -Gui, Add, Hotkey, % dpi("xp+90 yp w140 h20 vBGHKey"), %BGHKey% +Gui, Settings: Add, Hotkey, % dpi("xp+90 yp w140 h20 vBGHKey"), %BGHKey% -Gui, Add, Text, % dpi("x25 yp+35 w150 h16"), &Foreground mode (menu) -;Gui, Add, Radio, % dpi("xp+130 yp w45 h16 vFEsc"), Esc -;Gui, Add, Radio, % dpi("xp+45 yp w45 h16 vFWin"), Win -Gui, Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vFMod"), |Esc|Win +Gui, Settings: Add, Text, % dpi("x25 yp+35 w150 h16"), &Foreground mode (menu) +;Gui, Settings: Add, Radio, % dpi("xp+130 yp w45 h16 vFEsc"), Esc +;Gui, Settings: Add, Radio, % dpi("xp+45 yp w45 h16 vFWin"), Win +Gui, Settings: Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vFMod"), |Esc|Win + +Gui, Settings: Default If InStr(FGHKey,"#") { @@ -116,13 +119,15 @@ If InStr(FGHKey,"Esc &") GuiControl, Choose, FMod, 2 } -Gui, Add, Hotkey, % dpi("xp+90 yp w140 h20 vFGHKey"), %FGHKey% -;Gui, Add, Button, % dpi("xp+110 yp w30 h20 gButtonClearFG"), clear +Gui, Settings: Add, Hotkey, % dpi("xp+90 yp w140 h20 vFGHKey"), %FGHKey% +;Gui, Settings: Add, Button, % dpi("xp+110 yp w30 h20 gButtonClearFG"), clear + +Gui, Settings: Add, Text, % dpi("x25 yp+35 w150 h16"), Fil&tered mode (menu) +;Gui, Settings: Add, Radio, % dpi("xp+130 yp w45 h16 vTEsc"), Esc +;Gui, Settings: Add, Radio, % dpi("xp+45 yp w45 h16 vTWin"), Win +Gui, Settings: Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vTmod"), |Esc|Win -Gui, Add, Text, % dpi("x25 yp+35 w150 h16"), Fil&tered mode (menu) -;Gui, Add, Radio, % dpi("xp+130 yp w45 h16 vTEsc"), Esc -;Gui, Add, Radio, % dpi("xp+45 yp w45 h16 vTWin"), Win -Gui, Add, DropDownList, % dpi("xp+140 yp-3 w70 R3 vTmod"), |Esc|Win +Gui, Settings: Default If InStr(TMHKey,"#") { @@ -139,65 +144,66 @@ If InStr(TMHKey,"Esc &") GuiControl, Choose, Tmod, 2 } -Gui, Add, Hotkey, % dpi("xp+90 yp w140 h20 vTMHKey"), %TMHKey% -; Gui, Add, Button, % dpi("xp+110 yp w30 h20 gButtonClearTM"), clear +Gui, Settings: Add, Hotkey, % dpi("xp+90 yp w140 h20 vTMHKey"), %TMHKey% +; Gui, Settings: Add, Button, % dpi("xp+110 yp w30 h20 gButtonClearTM"), clear -Gui, Add, Button, % dpi("xp+170 yp-75 w120 h25 gButtonOK"), OK -Gui, Add, Button, % dpi("xp yp+40 w120 h25 gButtonClear"), Clear All Hotkeys -Gui, Add, Button, % dpi("xp yp+40 w120 h25 gGuiClose"), Cancel +Gui, Settings: Add, Button, % dpi("xp+170 yp-75 w120 h25 gButtonOK"), OK +Gui, Settings: Add, Button, % dpi("xp yp+40 w120 h25 gButtonClear"), Clear All Hotkeys +Gui, Settings: Add, Button, % dpi("xp yp+40 w120 h25 gSettingsGuiClose"), Cancel -Gui, Add, GroupBox, % dpi("x16 yp+40 w540 h72"), Other programs +Gui, Settings: Add, GroupBox, % dpi("x16 yp+40 w540 h72"), Other programs Checked:=MatchList.settings.Explorer -Gui, Add, Checkbox, % dpi("x25 yp+20 w60 h16 Checked" checked " vExplorer"), Explorer - -Gui, Add, Text, % dpi("xp+70 yp+1 w100 h20"), Double Commander: -Gui, Add, Hotkey, % dpi("xp+100 yp-3 w90 h20 vDoubleCommander"), % MatchList.settings.DoubleCommander -Gui, Add, Text, % dpi("xp+100 yp+3 w50 h20"), XYPlorer: -Gui, Add, Hotkey, % dpi("xp+50 yp-3 w90 h20 vXYPlorer"), % MatchList.settings.XYPlorer -Gui, Font, % dpi("s8 cGreen") -Gui, Add, Text, % dpi("xp+175 yp gFMMFileManText"), (?) -Gui, Font, % dpi("cBlack") -Gui, Font, ; see note above, required to reset style -Gui, Font, % dpi("s8") +Gui, Settings: Add, Checkbox, % dpi("x25 yp+20 w60 h16 Checked" checked " vExplorer"), Explorer + +Gui, Settings: Add, Text, % dpi("xp+70 yp+1 w100 h20"), Double Commander: +Gui, Settings: Add, Hotkey, % dpi("xp+100 yp-3 w90 h20 vDoubleCommander"), % MatchList.settings.DoubleCommander +Gui, Settings: Add, Text, % dpi("xp+100 yp+3 w50 h20"), XYPlorer: +Gui, Settings: Add, Hotkey, % dpi("xp+50 yp-3 w90 h20 vXYPlorer"), % MatchList.settings.XYPlorer +Gui, Settings: Font, % dpi("s8 cGreen") +Gui, Settings: Add, Text, % dpi("xp+175 yp gFMMFileManText"), (?) +Gui, Settings: Font, % dpi("cBlack") +Gui, Settings: Font, ; see note above, required to reset style +Gui, Settings: Font, % dpi("s8") Checked:=MatchList.settings.Everything -Gui, Add, Checkbox, % dpi("x25 yp+30 w100 h16 Checked" checked " vEverything"), Everything +Gui, Settings: Add, Checkbox, % dpi("x25 yp+30 w100 h16 Checked" checked " vEverything"), Everything ; Note: deactivated Everything Directory Tree and DocumentTemplates settings for now /* -Gui, Add, Text, % dpi("xp+70 yp+1 w100 h20"), Ev. Dir Tree: -Gui, Add, Hotkey, % dpi("xp+100 yp-3 w90 h20 vEVDirTree"), % MatchList.settings.EVDirTree +Gui, Settings: Add, Text, % dpi("xp+70 yp+1 w100 h20"), Ev. Dir Tree: +Gui, Settings: Add, Hotkey, % dpi("xp+100 yp-3 w90 h20 vEVDirTree"), % MatchList.settings.EVDirTree -Gui, Add, Text, % dpi("xp+100 yp+1 w50 h20"), Ev. Path: -Gui, Add, Edit , % dpi("xp+50 yp-5 w160 h21 vEvPath"), % MatchList.settings.EvPath ; % -Gui, Add, Button, % dpi("xp+165 yp w30 h20 gSelectEv"), >> +Gui, Settings: Add, Text, % dpi("xp+100 yp+1 w50 h20"), Ev. Path: +Gui, Settings: Add, Edit , % dpi("xp+50 yp-5 w160 h21 vEvPath"), % MatchList.settings.EvPath ; % +Gui, Settings: Add, Button, % dpi("xp+165 yp w30 h20 gSelectEv"), >> -Gui, Add, GroupBox, % dpi("x16 yp+45 w540 h70"), Currently Available Document Templates -Gui, Add, Edit, % dpi("x25 yp+20 ReadOnly h40 w385 vDocumentTemplates"), % MatchList.Settings.templatesExt -Gui, Add, Button, % dpi("xp+402 yp w120 h25 gButtonDocumentTemplates"), Update (scan) +Gui, Settings: Add, GroupBox, % dpi("x16 yp+45 w540 h70"), Currently Available Document Templates +Gui, Settings: Add, Edit, % dpi("x25 yp+20 ReadOnly h40 w385 vDocumentTemplates"), % MatchList.Settings.templatesExt +Gui, Settings: Add, Button, % dpi("xp+402 yp w120 h25 gButtonDocumentTemplates"), Update (scan) */ -;Gui, Add, GroupBox, x16 yp+40 w395 h60 , Misc. +;Gui, Settings: Add, GroupBox, x16 yp+40 w395 h60 , Misc. ;perhaps in future versions -;Gui, Add, Text, x25 yp+25 w150 h16 , Store set&tings in: -;Gui, Add, DropDownList, xp+225 yp-5 w140 h25 r2 Choose%SettingsFormat% vSettingsFormat AltSubmit, 1 - XML Format|2 - INI format +;Gui, Settings: Add, Text, x25 yp+25 w150 h16 , Store set&tings in: +;Gui, Settings: Add, DropDownList, xp+225 yp-5 w140 h25 r2 Choose%SettingsFormat% vSettingsFormat AltSubmit, 1 - XML Format|2 - INI format -Gui, Add, Link, % dpi("x25 yp+35"), F4MiniMenu %F4Version%: Open selected file(s) from TC in defined editor(s). More info at Github.com/hi5/F4MiniMenu. +Gui, Settings: Add, Link, % dpi("x25 yp+35"), F4MiniMenu %F4Version%: Open selected file(s) from TC in defined editor(s). More info at Github.com/hi5/F4MiniMenu. -;Gui, Add, GroupBox, xp+400 yp-85 w122 h60 -;Gui, Add, Link, xp+5 yp+13, Feedback welcome at`nTotal Commander forum`nor GitHub Issues. +;Gui, Settings: Add, GroupBox, xp+400 yp-85 w122 h60 +;Gui, Settings: Add, Link, xp+5 yp+13, Feedback welcome at`nTotal Commander forum`nor GitHub Issues. -Gui, Show, % dpi("center w570"), F4MiniMenu - Settings +Gui, Settings: Show, % dpi("center w570"), F4MiniMenu - Settings Return ButtonDocumentTemplates: Gosub, DocumentTemplatesScan +Gui, Settings: Default GuiControl,,DocumentTemplates, % MatchList.Settings.templatesExt Return ButtonOK: -Gui, Submit, NoHide +Gui, Settings: Submit, NoHide MatchList.settings.MenuPos:=MenuPos MatchList.settings.FilteredMenuAutoEdit:=FilteredMenuAutoEdit If (MaxFiles > 50) @@ -259,7 +265,7 @@ MatchList.settings.XYPlorer:=XYPlorer HotKeyState:="On" Gosub, SetHotkeys -Gui, Destroy +Gui, Settings:Destroy Gosub, SaveSettings Sleep 500 Reload ; v0.96 we may have changed F4MMClose so we need to reload the script to (de)activate the WinWait in F4MiniMenu.ahk @@ -267,6 +273,7 @@ Sleep 500 Return ButtonClear: +Gui, Settings: Default GuiControl, Choose, BMod, 0 GuiControl, Choose, FMod, 0 GuiControl, Choose, TMod, 0 @@ -275,16 +282,16 @@ GuiControl, , FGHKey, GuiControl, , TMHKey, Return -GuiEscape: -GuiClose: -Gui, Destroy +SettingsGuiEscape: +SettingsGuiClose: +Gui, Settings: Destroy HotKeyState:="On" Gosub, SetHotkeys Return FMMCloseHelpText: -MsgBox, 32, F4MMClose (experimental), +MsgBox, 8224, F4MMClose (experimental), (join`n F4MiniMenu - %F4Version% can automatically exit from memory using the following rules: @@ -298,7 +305,7 @@ If you have started (a new) Total Commander via F4MiniMenu, wait until that spec Return FMMFileManText: -MsgBox, 32, Other file managers (experimental), +MsgBox, 8224, Other file managers (experimental), (join`n F4MiniMenu can also work with other programs.`nTo activate enter the keyboard shortcut to "Copy Filename(s) with Full Path"`n` Double Commander default:`tShift+Ctrl+C`n diff --git a/lib/QDir.ahk b/lib/QDir.ahk index 2b0e8a4..2e79c73 100644 --- a/lib/QDir.ahk +++ b/lib/QDir.ahk @@ -6,6 +6,8 @@ QDir_Active() { IfWinActive ahk_exe Q-Dir.exe Return 1 + IfWinActive ahk_exe Q-Dir_x64.exe + Return 1 } QDir_GetSelection() diff --git a/lib/tc.ahk b/lib/tc.ahk new file mode 100644 index 0000000..ddeb1dd --- /dev/null +++ b/lib/tc.ahk @@ -0,0 +1,87 @@ +; TC_SendData() using WM_CopyData +; https://www.ghisler.ch/board/viewtopic.php?p=363391#p363391 + +/* +TESTED AND WORKING ON: AHK_L v 1.1.31.01 unicode & ansi version, Win 10 64bit and TC9.22 +modified by dindog +------------------------------------------------------------------------- +TC_SendData("em_FOO" , "EM") ; User Command +TC_SendData("em_APPENDTABS C:\my.tab", "EM") ; User Command with parameters (usercmd.ini as following) + ; [em_APPENDTABS] + ; cmd=APPENDTABS + ; param=%A +TC_SendData("em_CD C:", "EM") ; User Command with parameters (usercmd.ini as following) + ; [em_cd] + ; cmd=cd + ; param=%A +TC_SendData("em_命令 *.exe", "EM") ; User Command with parameters (usercmd.ini as following) test for command name non-ASCII + ; [em_命令] + ; cmd=cd + ; param=%A + +TC_SendData("cmd") ; Ask TC : (cmd one of the following varues:) + ; A = Active Side + + ; LP = Left Path RP = Right Path + ; LC = Left List Count RC = Right List Count + ; LI = Left Caret Index RI = Right Caret Index + ; LN = Left Name Caret RN = Right Name Caret + + ; SP = Source Path TP = Target Path + ; SC = Source List Count TC = Target List Count + ; SI = Source Caret Index TI = Target Caret Index + ; SN = Source Name Caret TN = Target Name Caret + +TC_SendData("C:\tc" "`r" "D:\data", "CD") ; CD Command: (LeftDir - RightDir) +TC_SendData("C:\tc" "`r" , "R") ; CD Command: (LeftDir) and activate Right panel +TC_SendData( "`r" "D:\data", "LT") ; CD Command: ( RightDir) in new tab and activate left panel + +TC_SendData("C:\tc" "`r" "D:\data", "S") ; CD Command: (SourceDir - TargetDir) +TC_SendData("C:\tc" "`r" , "SBT") ; CD Command: (SourceDir) in new background tab +TC_SendData( "`r" "D:\data", "ST") ; CD Command: ( TargetDir) in new background tab +S: Interpret the paths as source/target instead of left/right +T: Open path(s) in new tabs +B: Open tabs in background (do not activate them) +L: Activate the left panel +R: Activate the right panel +A: Do not open archives as directories. Instead, open parent directory and place cursor on it. +TC accepts more then 2 parameters here, so sending e.g. STBL is legitimate. +*/ + +TC_SendData(Cmd, CmdType="", msg="", hwnd="") { + Critical ; Define "OnMessage" as STATIC it is registered at Script startup. + STATIC om:=OnMessage(0x4a, "TC_SendData"), TC_ReceiveDataValue:="", TC_DataReceived:="" ; 0x4a is WM_COPYDATA + + IF ((msg=0x4A) AND (hwnd=A_ScriptHwnd)) ; EnSure is trigered by this Script. + EXIT (TC_ReceiveDataValue:=StrGet(NumGet(CmdType + A_PtrSize * 2)), TC_DataReceived:="1") + + VarSetCapacity(CopyDataStruct, A_PtrSize * 3), TC_ReceiveDataValue:=1, TC_DataReceived:="" + if (CmdType="") ; Ask TC + CmdType:=(A_IsUnicode ? "GW" : "GA"), TC_ReceiveDataValue:="" + else if (CmdType="EM") or (CmdType="em") ; em command + CmdType:="EM" + else ; CD command STBALR + DirType:=(CmdType="CD")?"":CmdType, CmdType:="CD" + + ;;;;;;VarSetCapacity need to request at least 5 more byte to allow 4 CD params + VarSetCapacity(cmdA, StrPut(cmd, (A_IsUnicode ?"UTF-8":"CP0")) + (CmdType="CD" ? 5 : 0) * (A_IsUnicode ? 2 : 1), 0) , Len:=StrPut(cmd, &cmdA, (A_IsUnicode ?"UTF-8":"CP0")) + + + + NumPut( Asc(SubStr(CmdType,1,1)) + 256 * Asc(SubStr(CmdType,2,1)), CopyDataStruct,0 ) + NumPut( Len + (CmdType="CD" ? 5 : 0) * (A_IsUnicode ? 2 : 1) , CopyDataStruct, A_PtrSize ) + NumPut( &cmdA , CopyDataStruct, A_PtrSize * 2) + Loop, % strlen(DirType) ;(CmdType=="CD" ? 2 : 0) + { + NumPut(Asc(SubStr(DirType,A_Index,1)), cmdA ,Len+A_Index-1, "Char") + } + SendMessage, 0x4A,%A_ScriptHwnd%, &CopyDataStruct,, ahk_class TTOTAL_CMD + + While (TC_ReceiveDataValue="") { + IfEqual, TC_DataReceived, 1, Break + IfGreaterOrEqual, A_Index, 500, Break + Sleep,10 + } + Return TC_ReceiveDataValue +} + diff --git a/readme.md b/readme.md index 6a7adb7..e263d6c 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,9 @@ -# F4MiniMenu - v1.1 +# F4MiniMenu - v1.2 A F4 Menu program for [Total Commander](http://www.ghisler.com/) to open selected file(s) in editor(s). -(and experimental/rudimentary support for Windows Explorer, Double Commander, XYPlorer, and Everything - only [when activated](#other-programs)) +(and experimental/rudimentary support for Windows Explorer, Double Commander, XYPlorer, and Everything - only [when activated](#other-programs)). + +It is a *standalone* program which runs separatly from Total Commander. See Getting Started. ## Features @@ -33,12 +35,12 @@ types. Several tools have been made to solve this problem, these include: While the original F4Menu[1] has quite a few options, this "clone" started out as a minimalistic program with only the basic functionality: opening multiple file types in various editors. -There are various methods to open selected files: regular, "[Drag & Drop](#drag-drop)", [Filelist](#filelist) +There are various methods to open selected files: regular, "[Drag & Drop](#drag--drop)", [Filelist](#filelist) or by making use of a [cmdline](#cmdline) option. There is 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](#f4tcie). +See [F4TCIE](#helper-script-f4tcieahk). There are *two* foreground menus: @@ -71,33 +73,49 @@ will take precedence. Set the F4MiniMenu shortcuts via the tray menu, right clic 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 +Do not edit the `F4MiniMenu.xml` or `F4MiniMenu.ini` settings file while the script is running, any changes made will be overwritten when the script exits. A backup is made at startup and saved as -"F4MiniMenu.xml.bak" or "F4MiniMenu.ini.bak" +`F4MiniMenu.xml.bak` or `F4MiniMenu.ini.bak` ### Disclaimer Use at your own risk. +# Getting Started + +Start `F4MiniMenu.ahk` (or `F4MiniMenu-64.exe`, `F4MiniMenu-32.exe`, available in [Releases](https://github.com/hi5/F4MiniMenu/releases)). + +Note that F4MiniMenu is a program that runs on its **own** and sits in the tray menu waiting +for Total Commander windows (and others if set up) to be _Active_ and the defined hotkeys to be +pressed to take action (e.g. _Edit files_, default: F4; or _Show a menu_ default: Esc+F4). +Access the settings and define(d) editors via the tray menu or [foreground menu](https://github.com/hi5/F4MiniMenu#screenshots) - Esc+F4. + +No changes to the TC settings are required, although there is a helper script (program), see [F4TCIE](#helper-script-f4tcieahk), +which does need to be defined as `editor` in the TC Settings for working with files in archives and FTP. + +Once F4MiniMenu is started, the Global settings and new editors with a variety of options (as outlined below) can be changed and added. + +(Additional information in the "Setup" section below.) + # Settings ## Global configuration -* Menu - - Position of Menu - - Accelerator key for full menu when using the filtered menu - - Show menu or Edit file directly when using the filtered menu +* Menu + - Position of Menu + - Accelerator key for full menu when using the filtered menu + - Show menu or Edit file directly when using the filtered menu * Files (Maximum number of files to be opened, will ask for confirmation if more are selected) * WinWait -- see below -* Total Commander - - TC Start - - TC Path - - Close F4MM options -* Hotkeys - - Background - - Foreground menu - - Filtered menu -* Other programs +* Total Commander + - TC Start + - TC Path + - Close F4MM options +* Hotkeys + - Background + - Foreground menu + - Filtered menu +* Other programs - Explorer, Double Commander, XYPlorer, Everything. __WinWait__ Set the maximum time in seconds to wait for the selected program window to appear before applying the selected Window Mode (Normal, Maximized, Minimized -- see Editor configuration). This should also prevent any unexpected "waiting" in case a program launch failed (crash, very slow program start etc). @@ -108,9 +126,9 @@ It may not be possible to edit (open) a new document during this defined waiting The following options can be set for each editor: -* Path to Program executable +* Path to Program executable. See Path variables. * Extensions as a comma separated list -* Parameters to pass on (if any) +* Parameters to pass on -- if any, see Parameters/Options. * Start directory (if any) * Method (normal, drag & drop, filelist, cmdline) -- see Methods below * Window Mode (Normal (often last used window size and position), Maximized, Minimized) @@ -118,9 +136,8 @@ The following options can be set for each editor: * Name to use in the menu as alternative to the program.exe (if any) * Drag & Drop delay in millisecond (time to wait before sending drag & drop command so program can start) * Open delay in milliseconds (time to wait before opening the first file so program can start) -* Use File name for WinMatch, rarely needed -- see below -## Path variables +## Path variables All path variables should be wrapped in `%` signs, examples: @@ -176,18 +193,18 @@ There are four methods to start a program and open the selected file(s). ## Normal This works in many cases and is similar to opening a file in TC by pressing enter or double click (or traditional F4). -When multiple files are selected and the program needs to be started first a delay per editor can be set before -attemping to open the second and other files. Delay for Open. (A similar delay can be set for Drag & Drop). +When multiple files are selected and the program(s) needs to be started first, a delay per editor can be set before +attemping to open the second and other files: Delay for Open. A similar delay can be set for Drag & Drop. Normal is the default method. ## Drag & Drop When the program is already running F4MM attempts to Drag & Drop the selected files into the application. If the program is not running, it is started using the normal method for the first file, then subsquent files are Drag & Dropped. In order to give the application some time to start, before D&D the second and -other files a delay can be set per editor - Delay for Drag & Drop. (A simlar delay can be set for Normal) +other files a delay can be set per editor - Delay for Drag & Drop. A simlar delay can be set for Normal. 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 +method used in this script. If it does not seem to work with a particular program, try the Normal or cmdline method(s). ## Filelist @@ -248,20 +265,26 @@ problems with slow programs. It is deleted when __F4MiniMenu__ starts or closes. ## Parameters/Options +(The TC file manager has two file panels side by side referred to as Source and Target) + |Parameter|Meaning| |---------|-------| -|%P |insert the source path into the command line, including a backslash \ at the end.| -|%T |insert the current target path, including a backslash \ at the end.| -|%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 parameters that follow. This allows the parameters to be changed before starting the program or prevent the programs execution.| -|---------|-------| -|%f41 |placeholder to alter position of filenames on the command line. (see example below)| - -|%N |places the filename under the cursor into the command line.| -|%M |places the current filename in the target directory into the command line.| - -Note: More _%f4_ fields may be added in the future. +|`%P` |insert the source path into the command line, including a backslash \ at the end.| +|`%T` |insert the current target path, including a backslash \ at the end. (TC only, see notes)| +|`%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 parameters that follow. This allows the parameters to be changed before starting the program or prevent the programs execution.| +|`%N` |places the filename under the cursor into the command line.| +|`%M` |places the current filename in the target directory into the command line.| +|`%$DATE:placeholders%`|See TC help, "Environment variables". Valid placeholders: y,Y,M,D,h,H,i1,i,m,s.| +|**F4MM specific options:**|-------| +|`%f41` |placeholder to alter position of filenames on the command line. (see notes and example below)| +|`%$DATE:placeholders\|Value\|TimeUnits%`|if _Value_ and _TimeUnits_ are present, these parameters allow for "Date & Time Math" to add or substract TimeUnits. TimeUnits can be either `Seconds`, `Minutes`, `Hours`, or `Days`. See TimeUnits of the https://www.autohotkey.com/docs/v1/lib/EnvAdd.htm command.| + +Notes: + +1. More _%f4_ fields may be added in the future. +2. %T for other file managers %T will use the same value as %P *Example: %f41* @@ -279,6 +302,10 @@ in the parameters field it will instruct F4MiniMenu where to place the files on So the program now starts as _pdftk.exe file.pdf burst_ (instead of _pdftk.exe burst file.pdf_) +*Example: %$DATE:placeholders|Value|TimeUnits%* + +`%$DATE:Y-M-D|7|Days%` -> A week from now e.g. add 7 Days ahead. -7 would be last week. + # Helper script: F4TCIE.ahk Use F4TCIE for editing files in: @@ -306,7 +333,7 @@ To configure Total Commander to use F4TCIE.ahk: If for some reason the configuration can not be opened, an attempt is made to start the editor for the file type associated in Windows (so for txt -> notepad, for bmp,jpg -> MS Paint etc). -When there is no editor for the file type notepad.exe is started. +When there is no editor for the file type found `notepad.exe` is started. Reference: see also [#13](https://github.com/hi5/F4MiniMenu/issues/13) @@ -329,7 +356,7 @@ More information can be found in the [DocumentTemplates README](DocumentTemplate ### Script Download the source as a ZIP from GitHub here -and unpack. To start it simply run F4MiniMenu.ahk. Setup F4MiniMenu using the tray menu +and unpack. To start it simply run `F4MiniMenu.ahk`. Setup F4MiniMenu using the tray menu options for *Settings* and *Configure editors*. Once the shortcuts have been setup access *Settings* and *Configure editors* via the Foreground @@ -361,7 +388,7 @@ Automatically close F4MiniMenu using the following options (available via Settin **Important** Do not use passive mode when F4MiniMenu is already running. -First parameter must be the file list which contains the selected files in Total Commander or Double Commander (refer to file manager documentation for further information) +First parameter must be the file list which contains the selected files in Total Commander or Double Commander (refer to file manager documentation for further information). Optional parameters are /P1, /P2, /M1, and /M2 @@ -454,6 +481,7 @@ __Editor configuration__ * [XA Save / Load Arrays to/from XML Functions](https://github.com/hi5/XA) * [DropFilesA - SKAN](http://www.autohotkey.com/board/topic/41467-make-ahk-drop-files-into-other-applications/#entry258810) including Unicode version [nimda](http://www.autohotkey.com/board/topic/79145-help-converting-ahk-ahk-l/#entry502676) * [OSDTIP_Pop() - SKAN](https://www.autohotkey.com/boards/viewtopic.php?t=76881#p333577) +* [TC_SendData() - dindog and others](https://www.ghisler.ch/board/viewtopic.php?p=363391#p363391) - using WM_CopyData ## Changelog