From 881bddb0478c1b25d17d510a53529d9cd546825e Mon Sep 17 00:00:00 2001 From: hi5 Date: Sat, 15 Jul 2017 11:51:40 +0200 Subject: [PATCH] v0.95 - Helper script F4TCIE, DocumentTemplates, New icon --- .../DocumentTemplatesExamples.zip | Bin 0 -> 2419 bytes DocumentTemplates/readme.md | 40 +++++++ F4MiniMenu.ahk | 108 +++++++----------- F4TCIE.ahk | 95 +++++++++++++++ inc/HelperFunctions.ahk | 15 +++ inc/LoadSettings1.ahk | 20 ++++ inc/LoadSettings2.ahk | 14 +++ inc/Menu.ahk | 3 + inc/Settings.ahk | 13 ++- inc/TotalCommanderPath.ahk | 16 +++ readme.md | 53 +++++++-- res/f4.ico | Bin 1150 -> 1150 bytes 12 files changed, 298 insertions(+), 79 deletions(-) create mode 100644 DocumentTemplates/DocumentTemplatesExamples.zip create mode 100644 DocumentTemplates/readme.md create mode 100644 F4TCIE.ahk create mode 100644 inc/HelperFunctions.ahk create mode 100644 inc/LoadSettings1.ahk create mode 100644 inc/LoadSettings2.ahk create mode 100644 inc/TotalCommanderPath.ahk diff --git a/DocumentTemplates/DocumentTemplatesExamples.zip b/DocumentTemplates/DocumentTemplatesExamples.zip new file mode 100644 index 0000000000000000000000000000000000000000..3e4959578a2a9691d9a3a98c6152000ad290c7c7 GIT binary patch literal 2419 zcmZ{mc`zG_7RD1>qSmTXK?SizsTP-5DzOt=w@|euSBu)ySdwaQY168ul%n=pqn4sX zJQB4pMNqv;YiTL5*AiN_J$K&Bo%?3qJLk-NbLPzV=kLttfac^91#kes094MRHS+G` z@OVxD0K*3W@B;ti%O8Yj0R6DnE7}|EW&74ms@V zcWjxAL|rtA6|gOZxpsl~ru5}^xVu7Q{RcUsbTy@z5g8zh1UXnX-$MRz0q?tNFm+6W z4>O!dTvx6QQ~6VjSCO!$x$tncRb0LH){W>yr|qFW=uH`qXZz?~9n~w$1l7&u07MyM zCB#8WT(MJ$=aAoA5dM)8(WIlzl^z#1Ce2kK)4`WlWc%0y!$_aD=<^V+!;rYz#x_9A zNfL|Z<-SYQ5C*q-U}3eI+e${*Jy&@zWVv$kyX!I%fq<|B7?4yd4ON_kTC=W%;7mGHXrxW=v};W1}DcAn1*mRh zpq6%o^`PHwkXg1qw?$1WC<6jK82O|ee$8#xarWfljL{6_ZFKJG(xHO`iu%uim+yP4 z%gxO$U!_aU+F)YhQ!pQ?IO4FVbBm>2431x+;k?}p>=H0YqrY9`ZO~l0cdAXTsbrUf zO7ll-nkHTD=DoOM2pL9H`Rz!9V4 zpWoVJ;bLEdO}9{fC$(S}(TvW1ofGg$#1&&X;Q7LN8vdIGHrJ|M)R#(XV~0w+ZH!3{ zib!fT791Z;@IVots2yPaQHTLdezNq#(6zDQSRnfQAFK!#kyS^LE2gyI8^b111O3t? zorZ#n>?pHWIa?<}@LOJ_E*Pg9(vti_^gu~up(;_KzIgpuFM*~I28t%Ml*%Gtj{~S? za1(hw)%ad-+`*@dJJMlJwLPW3$&1-1Kk1F7byNh;iH&DnigO-YlyvwT+p|a5O0@L3 zfVlwx%_C<23)`Roua(qY`(ejZokD39<;p4KNI6k%9qp&Q`JwRI>8j^8B@F_Y8=;c8 zi-j)mS`Xl3`S~k)Z4f^&!LF_$Na&^5d%#X!C);_xTGf4|#wK=&Mz8BET~ z`qr<6VBO7O*)nI_tk%oEMg{?z7r9)1em2_D0Gt`sa##Kt z-(oSLgpCq>iUdM^+8S5p-20MHX7-o-aAyGi{DGf^z5~CgSx3k2XZ%(Tjc2r9ktJVt z<;>r3KWX%FTWZkkNe4Etln8dpH% z-t7I|6gWZG-Ar}&+u}w25T(zRE{)7^6H6(Yzf*ThJU_Eb?CU0lT)G2s1v9D-Mp9^7 z?7@_T*Z$(88<2wd86N?Pr`9YrG>MCmU+-k5)&I88+dWwR+_{yC3PfPeA)_!A$(Oq< zBYYp;(_fAp`hpzQj`0!#eLWY-sU`=H$rnD*qURdt#f5urrdl{2+ltw>QLO%u6R52o z_Y$7*goBMUM@0@<&FF#ZIP%zW6G+`qzv+NF7nsPHE#5|afgD=L6u(}h?`!O^7@;?D zN8$eQS|uS8AUS=zK8YeuoKir?^0%#L(ym&yk9KxOn)LK5h2NRb3^_jurkrys9{tr! zFDzyzSUk$Xw2DwO-xRv`T19C0P)U&h(czhjhQ6b0aA2p`bU+u9Um5=)9$U-NW znY9cCV=6=(_N%MlH9kL$C;uC}sO49@Q$s)Y&-B78h*d~z$D-tq($g16d(3ObSg)ze zQs{p5knxnX4=**v*xzURA%cw}5|?Xrhtm)vSw)A2r>}+M7q&c{d%k6#DODI1(5(zR4B1voa&xnH=0r7Z*^0iKxuRy}90%>xaG*(U@ORL#0wFU5fgZs&31l zZIV9xxlzEs|Cu{pY<-Zn6i4Sjc#+ddsn>m+W8dga=Ez#@uRl;N~q}=dd!$Lm4K;XVS>4n53Z1AXe&Q6GJ zhSil-hJ<_CJGtWG;(I5G{K^$mMU#4*OJ?;*KbBWPO9jLGJoJF8xypJBC%5lsAduWI zmp+sp+#)^+kxgoSw##7_`nc%YMq#LKbYyTjA)c)tZ{iMJR<$-yNzE*aXpfP*8)bdo z_*u;mu!j^`?}u>j?TXg8V^BZ{#WyTuZOJHYV+)>Ij_HkZD*~@F|4w zxE1+ssv0zxUwF87Xg*G^7Z#s3c8TT-mOYHrHPH92{$57T!_S8ai3looXv_R;T9$D@ z135$i|3B&+r5yke0R2mj>Yu^qpU(gFZU5td9trIzI{ocD`n?WlZl1rc97jz!(gpBe G+rI&8_+AqL literal 0 HcmV?d00001 diff --git a/DocumentTemplates/readme.md b/DocumentTemplates/readme.md new file mode 100644 index 0000000..4dc4ff2 --- /dev/null +++ b/DocumentTemplates/readme.md @@ -0,0 +1,40 @@ +# Document Templates for F4TCIE.ahk + +Note that this is an additional functionality, if you don't place any template.* files +in this folder F4TCIE will not use it. + +## Introduction + +By default you can use the keyboard shortcut Shift+F4 or the +*cm_EditNewFile* command to create a new text file and open this in your defined text +editor. + +By setting F4TCIE.ahk as editor: + + TC, Configuration, Edit/View, Editor: + drive:\path-to\F4TCIE.ahk "%1" + +you can extend this functionality to the programs you defined in F4MiniMenu. + +Unlike text editors, many program simply don't accept or understand the new empty +file Total Commander creates. They may not start correctly or generate an error message. +Here is where F4TCIE comes in. It checks if there is a "template.ext" file for the new +file you just created, if so it copies that template to your current active panel and +start your preferred program which you defined in F4MiniMenu. + +So instead of opening your text editor when you create a new "MyImageFile.PNG" it +can start your preferred Graphics program for PNG files. + +If it can't find a template, it will simply launch your default editor. + +When you add new templates to this folder you need to Update (scan) the +"Currently Available Document Templates" in the Settings window, or via +"Scan Document Templates" in the Tray or Foreground menu OR restart F4MiniMenu. + +You can find two examples in DocumentTemplatesExamples.zip to illustrate how it +works (RTF, PNG) - you can of course replace these with your own Template files. + +## Limitation(s) + +* It won't work in/with ZIP files (but will copy file to Active panel) +* Shift+F4 doesn't work in FTP panels (default TC behaviour) diff --git a/F4MiniMenu.ahk b/F4MiniMenu.ahk index 76d4b95..19fd33f 100644 --- a/F4MiniMenu.ahk +++ b/F4MiniMenu.ahk @@ -1,9 +1,9 @@ /* Script : F4MiniMenu.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode) -Version : 0.94c +Version : 0.95 Author : hi5 -Last update : 7 June 2017 +Last update : 10 July 2017 Purpose : Minimalistic clone of the F4 Menu program for Total Commander (open selected files in editor(s)) Source : https://github.com/hi5/F4MiniMenu @@ -32,25 +32,10 @@ If (TmpFileList = "") TmpFileList .= "\$$f4mtmplist$$.m3u" -F4Version:="v0.94c" +F4Version:="v0.95" -SplitPath, A_ScriptName, , , , OutNameNoExt -If (SubStr(OutNameNoExt,0) <> "i") - { - F4ConfigFile:="F4MiniMenu.xml" - F4Load:="XA_Load" - F4Save:="XA_Save" - } -else - { - F4ConfigFile:="F4MiniMenu.ini" - F4Load:="iob" - F4Save:="iob_save" - } - -Error:=0 -; http://en.wikipedia.org/wiki/List_of_archive_formats -ArchiveExtentions:="\.(a|ar|cpio|shar|iso|lbr|mar|tar|bz2|F|gz|lz|lzma|lzo|rz|sfark|xz|z|infl|7z|s7z|ace|afa|alz|apk|arc|arj|ba|bh|cab|cfs|cpt|dar|dd|dgc|dmg|gca|ha|hki|ice|j|kgb|lzh|lha|lzx|pak|partimg|paq6|paq7|paq8|pea|pim|pit|qda|rar|rk|sda|sea|sen|sfx|sit|sitx|sqx|tar\.gz|tgz|tar\.Z|tar\.bz2|tbz2|tar\.lzma|tlz|uc|uc0|uc2|ucn|ur2|ue2|uca|uha|wim|xar|xp3|yz1|zip|zipx|zoo|zz)\\" +; shared with F4TCIE +#Include %A_ScriptDir%\inc\LoadSettings1.ahk GroupAdd, TCF4Windows, ahk_class TTOTAL_CMD GroupAdd, TCF4Windows, ahk_class TLister @@ -65,32 +50,23 @@ Menu, tray, NoStandard Menu, tray, Add, F4MiniMenu - %F4Version%, DoubleTrayClick Menu, tray, Default, F4MiniMenu - %F4Version% Menu, tray, Add, -Menu, tray, Add, &Reload this script, MenuHandler -Menu, tray, Add, &Edit this script, MenuHandler +Menu, tray, Add, &Reload this script, MenuHandler +Menu, tray, Add, &Edit this script, MenuHandler Menu, tray, Add, -Menu, tray, Add, &Suspend Hotkeys, MenuHandler -Menu, tray, Add, &Pause Script, MenuHandler +Menu, tray, Add, &Suspend Hotkeys, MenuHandler +Menu, tray, Add, &Pause Script, MenuHandler Menu, tray, Add, -Menu, tray, Add, Settings, Settings -Menu, tray, Add, Configure editors, ConfigEditors +Menu, tray, Add, Settings, Settings +Menu, tray, Add, Configure editors, ConfigEditors +Menu, tray, Add, Scan Document Templates, DocumentTemplatesScan Menu, tray, Add, Menu, tray, Add, Exit, SaveSettings If !FileExist(F4ConfigFile) and !FileExist(F4ConfigFile ".bak") ; most likely first run, no need to show error message Gosub, CreateNewConfig -; Load settings on MatchList Object -Try - { - %F4Load%(F4ConfigFile) - } -Catch - { - Error:=1 - } - -If ((MatchList.MaxIndex() = 0) or (MatchList.MaxIndex() = "")) - Error:=1 +; shared with F4TCIE +#Include %A_ScriptDir%\inc\LoadSettings2.ahk If (Error = 1) { @@ -115,20 +91,10 @@ If (MatchList.settings.TCStart = 1) and !WinExist("ahk_class TTOTAL_CMD") Run % MatchList.settings.TCPath ; % } -; try to get Commander_Path, it will be empty if TC is not running (yet) -EnvGet, Commander_Path, Commander_Path +; shared with F4MM +#Include %A_ScriptDir%\inc\TotalCommanderPath.ahk -If (Commander_Path = "") ; try to read registry - RegRead Commander_Path, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, InstallDir - -; Inform user just in case -If (Commander_Path = "") - { - FileRead, check_for_path, %F4ConfigFile% - If InStr(check_for_path,"%Commander_Path%") - MsgBox, 16, F4MiniMenu: Not found, F4MiniMenu:`nThe Commander_Path environment variable can not be found.`nStarting applications may not work in some cases.`nStart TC first. - check_for_path:="" - } +Gosub, DocumentTemplatesScan Gosub, BuildMenu @@ -206,7 +172,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1") { FileList%Index% .= open "`n" Done.Insert(open) - } + } } Else If (SelectedEditor > 0) ; Use selected editor from the Menu (Foreground option) { @@ -228,7 +194,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1") Loop, parse, list, `n, `r cmdfiles .= """" A_LoopField """" A_Space OpenFile(v, cmdfiles) - cmdfiles:="" + cmdfiles:="" } else If (v.Method = "FileList") { @@ -474,14 +440,6 @@ CountFiles(Files) Return ErrorLevel+1 } -GetTCCommander_Path(editor) - { - global MyComSpec - editor:=StrReplace(editor,"%Commander_Path%",Commander_Path) - editor:=StrReplace(editor,"%ComSpec%",MyComSpec) - Return editor - } - GetTCFields(opt,file="") { ; %P causes the source path to be inserted into the command line, including a backslash (\) at the end. @@ -589,12 +547,6 @@ AllExtensions:=Trim(AllExtensions,",") AllExtensions:=RegExExtensions(AllExtensions) Return -RegExExtensions(in) - { - out:="iU)\b(" StrReplace(StrReplace(StrReplace(in,",","|"),"?",".?"),"*",".*") ")\b" ; v0.9 allow for wildcards - Return out - } - CreateNewConfig: if InStr(F4ConfigFile,"xml") { @@ -642,13 +594,31 @@ windowmode=1 } Return + +; Check DocumentTemplates\ - this setting can be used in F4TCIE.ahk (not required) +DocumentTemplatesScan: +If (FileExist(A_ScriptDir "\DocumentTemplates\") = "D") + { + Loop, %A_ScriptDir%\DocumentTemplates\template.* + { + SplitPath, A_LoopFileName, , , TemplatesOutExtension + templatesExt .= TemplatesOutExtension "," + } + MatchList.Settings["templatesExt"]:=Trim(templatesExt,",") + TemplatesOutExtension:="" + templatesExt:="" + %F4Save%("MatchList", F4ConfigFile) + } +Return + ; Includes #include %A_ScriptDir%\inc\Menu.ahk #include %A_ScriptDir%\inc\Settings.ahk #include %A_ScriptDir%\inc\Editors.ahk -#include %A_ScriptDir%\lib\XA.ahk -#include %A_ScriptDir%\lib\iob.ahk +#include %A_ScriptDir%\inc\HelperFunctions.ahk ; shared with F4TCIE +#include %A_ScriptDir%\lib\XA.ahk ; shared with F4TCIE +#include %A_ScriptDir%\lib\iob.ahk ; shared with F4TCIE #include %A_ScriptDir%\lib\class_lv_rows.ahk #include %A_ScriptDir%\lib\DropFiles.ahk #include %A_ScriptDir%\lib\GetPos.ahk diff --git a/F4TCIE.ahk b/F4TCIE.ahk new file mode 100644 index 0000000..e176892 --- /dev/null +++ b/F4TCIE.ahk @@ -0,0 +1,95 @@ +/* + +Script : F4TCIE.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode) +Version : 0.4 +Author : hi5 +Last update : 10 July 2017 +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" + and "cmdline" methods will not be used (TC doesn't see file changes when using these methods) + If you are using INI make sure to rename "F4TCIE" to end with an "i" (same method as F4MiniMenu) +Source : https://github.com/hi5/F4MiniMenu + +Setup : TC, Configuration, Edit/View, Editor: + drive:\path-to\F4TCIE.ahk "%1" + +Templates : Create a DocumentTemplates\ folder and place files for each template you'd like to use for + the Shift-F4 'enter file name to edit' function of TC. File names are template.ext + This will copy the template.ext to the panel with the new name so you can work on it the + defined editor. Not all programs allow empty files at start up so this will resolve that + problem for say Office applications or Graphics programs. + For testing purposes the variable "templateExt" below needs to be modified, this will + be automatically done when integrating F4TCIE into the F4MM repo. + See DocumentTemplates\readme.md for more info. + +*/ + +#NoTrayIcon +#NoEnv + +SetWorkingDir, %A_ScriptDir% + +File=%1% ; cmd line parameter "%1" it receives from TC +SplitPath, File, , , OutExtension +StringUpper, OutExtension, OutExtension + +If !File ; if empty + ExitApp + +; shared with F4MM +#Include %A_ScriptDir%\inc\LoadSettings1.ahk +#Include %A_ScriptDir%\inc\LoadSettings2.ahk + +If Error + { + MsgBox, 16, F4MiniMenu/F4TCIE, Couldn't load configuration file, closing script and starting default Windows editor.`n`nMay not work if there is no "Edit" defined for this filetype:`n`n%OutExtension% + Try + Run edit %file% ; run Windows editor for this filetype + Catch + Run notepad %file% ; alas no type defined so run notepad as a last resort + ExitApp + } + +templateExt:=MatchList.Settings.templatesExt + +; shared with F4MM +#Include %A_ScriptDir%\inc\TotalCommanderPath.ahk + +for k, v in MatchList + { + if (k = "settings") + 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 + { + editor:=GetTCCommander_Path(v.exe) + If OutExtension in %templateExt% + { + IfExist, %file% ; file is already present, this could be that TC created it just now (0 bytes) or that is already existed. + { + FileGetSize, NewFileSize, %file% + If (NewFileSize = 0) ; TC created it, so overwrite with our template, otherwise don't. This to avoid overwriting existing documents. + FileCopy, %A_ScriptDir%\DocumentTemplates\template.%OutExtension%, %file%, 1 + } + } + If editor + { + Sleep % v.delay + Run %editor% %file% + } + ExitApp ; we only have one file to proces so we're done + } + } + +; We couldn't find a defined Editor so launch the default Editor [1] +Run % matchlist[1].exe A_Space file + +; shared with F4MM +#include %A_ScriptDir%\inc\HelperFunctions.ahk + +; 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/inc/HelperFunctions.ahk b/inc/HelperFunctions.ahk new file mode 100644 index 0000000..b650ac0 --- /dev/null +++ b/inc/HelperFunctions.ahk @@ -0,0 +1,15 @@ +; used in F4MiniMenu and F4TCIE + +GetTCCommander_Path(editor) + { + global MyComSpec + editor:=StrReplace(editor,"%Commander_Path%",Commander_Path) + editor:=StrReplace(editor,"%ComSpec%",MyComSpec) + Return editor + } + +RegExExtensions(in) + { + out:="iU)\b(" StrReplace(StrReplace(StrReplace(in,",","|"),"?",".?"),"*",".*") ")\b" ; v0.9 allow for wildcards + Return out + } diff --git a/inc/LoadSettings1.ahk b/inc/LoadSettings1.ahk new file mode 100644 index 0000000..a9abfc5 --- /dev/null +++ b/inc/LoadSettings1.ahk @@ -0,0 +1,20 @@ +; used in F4MiniMenu and F4TCIE + +SplitPath, A_ScriptName, , , , OutNameNoExt +If (SubStr(OutNameNoExt,0) <> "i") + { + F4ConfigFile:="F4MiniMenu.xml" + F4Load:="XA_Load" + F4Save:="XA_Save" + } +else + { + F4ConfigFile:="F4MiniMenu.ini" + F4Load:="iob" + F4Save:="iob_save" + } + +Error:=0 +; http://en.wikipedia.org/wiki/List_of_archive_formats +ArchiveExtentions:="\.(a|ar|cpio|shar|iso|lbr|mar|tar|bz2|F|gz|lz|lzma|lzo|rz|sfark|xz|z|infl|7z|s7z|ace|afa|alz|apk|arc|arj|ba|bh|cab|cfs|cpt|dar|dd|dgc|dmg|gca|ha|hki|ice|j|kgb|lzh|lha|lzx|pak|partimg|paq6|paq7|paq8|pea|pim|pit|qda|rar|rk|sda|sea|sen|sfx|sit|sitx|sqx|tar\.gz|tgz|tar\.Z|tar\.bz2|tbz2|tar\.lzma|tlz|uc|uc0|uc2|ucn|ur2|ue2|uca|uha|wim|xar|xp3|yz1|zip|zipx|zoo|zz)\\" + diff --git a/inc/LoadSettings2.ahk b/inc/LoadSettings2.ahk new file mode 100644 index 0000000..619b175 --- /dev/null +++ b/inc/LoadSettings2.ahk @@ -0,0 +1,14 @@ +; used in F4MiniMenu and F4TCIE + +; Load settings on MatchList Object +Try + { + %F4Load%(F4ConfigFile) + } +Catch + { + Error:=1 + } + +If ((MatchList.MaxIndex() = 0) or (MatchList.MaxIndex() = "")) + Error:=1 diff --git a/inc/Menu.ahk b/inc/Menu.ahk index aa8c824..2989af2 100644 --- a/inc/Menu.ahk +++ b/inc/Menu.ahk @@ -55,6 +55,9 @@ Menu, MyMenu, Add, %MenuPadding%Settings, MenuHandler Menu, MyMenu, Icon, %MenuPadding%Settings, shell32.dll, 170 Menu, MyMenu, Add, %MenuPadding%Configure Editors, ConfigEditors Menu, MyMenu, Icon, %MenuPadding%Configure Editors, shell32.dll, 70 +Menu, MyMenu, Add, %MenuPadding%Scan Document Templates, DocumentTemplatesScan +Menu, MyMenu, Icon, %MenuPadding%Scan Document Templates, shell32.dll, 172 + Menu, MyMenu, Add, %MenuPadding%Exit, MenuHandler Menu, MyMenu, Icon, %MenuPadding%Exit, shell32.dll, 132 diff --git a/inc/Settings.ahk b/inc/Settings.ahk index 126ffc3..41d525a 100644 --- a/inc/Settings.ahk +++ b/inc/Settings.ahk @@ -96,17 +96,26 @@ Gui, Add, Button, xp+177 yp-48 w120 h25 gButtonOK, OK Gui, Add, Button, xp yp+30 w120 h25 gButtonClear, Clear Hotkeys Gui, Add, Button, xp yp+30 w120 h25 gGuiClose, Cancel +Gui, Add, GroupBox, x16 yp+35 w540 h70 , Currently Available Document Templates: +Gui, Add, Edit, x25 yp+20 ReadOnly h40 w385 vDocumentTemplates, % MatchList.Settings.templatesExt +Gui, Add, Button, xp+402 yp w120 h25 gButtonDocumentTemplates, Update (scan) + ;Gui, 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, Add, Link, x25 yp+45, F4MiniMenu %F4Version%: Open selected file(s) from TC in defined editor(s). More info at Github.com/hi5/F4MiniMenu. +Gui, Add, Link, x25 yp+65, 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, Show, center w570 h315 , Settings +Gui, Show, center w570 h390 , Settings +Return + +ButtonDocumentTemplates: +Gosub, DocumentTemplatesScan +GuiControl,,DocumentTemplates, % MatchList.Settings.templatesExt Return ButtonOK: diff --git a/inc/TotalCommanderPath.ahk b/inc/TotalCommanderPath.ahk new file mode 100644 index 0000000..c00d7bb --- /dev/null +++ b/inc/TotalCommanderPath.ahk @@ -0,0 +1,16 @@ +; used in F4MiniMenu and F4TCIE + +; try to get Commander_Path, it will be empty if TC is not running (yet) +EnvGet, Commander_Path, Commander_Path + +If (Commander_Path = "") ; try to read registry + RegRead Commander_Path, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, InstallDir + +; Inform user just in case +If (Commander_Path = "") + { + FileRead, check_for_path, %F4ConfigFile% + If InStr(check_for_path,"%Commander_Path%") + MsgBox, 16, F4MiniMenu: Not found, F4MiniMenu:`nThe Commander_Path environment variable can not be found.`nStarting applications may not work in some cases.`nStart TC first. + check_for_path:="" + } diff --git a/readme.md b/readme.md index 65fad95..10eac14 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# F4MiniMenu - v0.94c +# 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 @@ -19,9 +19,13 @@ types. Several tools have been made to solve this problem, these include: * and of course [F4Menu](http://ghisler.ch/board/viewtopic.php?t=17003) - 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. An additional feature -is that it can open selected files using a "[Drag & Drop](#dragdrop)" method (a personal requirement) -or by preparing a [Filelist](#filelist). +basic functionality: opening multiple file types in various editors. There are various +methods to open selected files: regular, "[Drag & Drop](#dragdrop)", [Filelist](#filelist) +or by making use of a [cmdline](#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](#f4tcie). *First come, first serve* @@ -30,7 +34,7 @@ __extension__. If it can not find a match it will open the file(s) in the defaul The default editor is the first editor listed in the [*Configure editors*](#screenshots) 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](#screenshots) option. -see below. +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. @@ -121,18 +125,49 @@ Once you have setup your shortcuts you can also access *Settings* and *Configure via the Foreground menu options by pressing the shortcut (press Esc+F4 by default). See screenshots below. -There are two versions: +**XML or INI** - There are two versions: 1. F4MiniMenu.ahk uses XML to store settings (F4MiniMenu.xml) 2. 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. +so rename or copy F4MiniMenu.ahk to F4MiniMenui.ahk and start. That would work, but F4MMi.exe as well. *Executable* If you wish you can compile the script to a standalone executable using [AHK2Exe](https://autohotkey.com/download/). [Documentation](https://autohotkey.com/docs/Scripts.htm#ahk2exe) +## Helper script: F4TCIE.ahk + +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) + +**Setup F4TCIE** + +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](https://github.com/hi5/F4MiniMenu/issues/13) + +## DocumentTemplates + +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](DocumentTemplates/readme.md) + # Parameters/Options |Field|Meaning| @@ -214,7 +249,9 @@ __Editor configuration__ ## Changelog -* 20170607 - v0.94c Minor fix to prevent empty file and quoted startdir variables in GetInput(). Fix for %ComSpec% in Program names. +* 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 diff --git a/res/f4.ico b/res/f4.ico index 55f7c2e20231c61c92575e4b1f8a5349a47976b4..50d2e6f2d4e6379c9faedef4e1bd2f89454b3a00 100644 GIT binary patch literal 1150 zcmcJOF-yZ>5QZ;kaP8#m=q}>oQo+H0qVDd_;veuo^dAH&SV(IKA&s%dG$hvAV5vyK zSzhl_@)1fa`2;V#Idbsad*3A?GWcpVi0?aex=FN6M7u05ab;2Gv^KJH1G*}k3720V zYD+ljA$f9j0G$xObv(CR*{WLqZ{9RbIa@J@0D4Z-6%mS`H|X(W)Tro(8wGS^$TZZ6x1^yMLH%1;k{#2YBu@XmHM`p27Gp$|#~I+bAYXBXjPI@k&S*cG4G zatS`8603x@_lelnyq)KMIwxz4!@zpUJY+qGCG$o6=umJh=@nqB^=1~9-{xZFT`rHy z`dn=8CHbp^DlD4n;ci!?!1T{=WMScrg5%q31v~`CVe4sAR*JjQuflxq1x&xpNr7=5 zUCqSfYnga*Jrgspa`2GO3~VKHrdj-?f~)&HzC7EJ0w?|1zP4s>KBn>{f4=(+W_#-4 zYTu1TLmqrRrJU2DEk=Bz7IBA)pW}{N=ykT(0Ly$+0bG<=V0LC-uig=XA zPw_h24BCAVt%td0ef%;4qZ)|j{p42xX{0K}OD3|dhI~&zwk5o!ks8hw&Bch=8xR zBlF^Z^lhYJnwe%4E#-XPU!(~-nu0#JsUc#i+=$Wryf<_ZB5~P0?3;=lbSKwSkNg=g lI#_|#xz1+x5Bfblnvk=_D|ucZ9R!^%LBG3;YnlFk)^9h|^>+XO