Skip to content

Commit

Permalink
v0.97 - Filtered foreground menu; various fixes and improvements - se…
Browse files Browse the repository at this point in the history
…e changelog.md
  • Loading branch information
hi5 committed Jun 30, 2019
1 parent c925333 commit ca34aeb
Show file tree
Hide file tree
Showing 8 changed files with 398 additions and 161 deletions.
112 changes: 79 additions & 33 deletions F4MiniMenu.ahk
@@ -1,9 +1,9 @@
/*
Script : F4MiniMenu.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode)
Version : 0.96.2
Version : 0.97
Author : hi5
Last update : 27 May 2019
Last update : 30 June 2019
Purpose : Minimalistic clone of the F4 Menu program for Total Commander (open selected files in editor(s))
Source : https://github.com/hi5/F4MiniMenu
Expand All @@ -13,7 +13,7 @@ Note : ; % used to resolve syntax highlighting feature bug of N++

; <for compiled scripts>
;@Ahk2Exe-SetDescription F4MiniMenu: Open files from TC
;@Ahk2Exe-SetVersion 0.96.2.0
;@Ahk2Exe-SetVersion 0.97.0.0
;@Ahk2Exe-SetCopyright MIT License - Copyright (c) https://github.com/hi5
; </for compiled scripts>

Expand Down Expand Up @@ -44,7 +44,7 @@ If (TmpFileList = "")

TmpFileList .= "\$$f4mtmplist$$.m3u"

F4Version:="v0.96.2"
F4Version:="v0.97"

; shared with F4TCIE
#Include %A_ScriptDir%\inc\LoadSettings1.ahk
Expand Down Expand Up @@ -94,7 +94,7 @@ Menu, tray, Add, Scan Document Templates, DocumentTemplatesScan
Try
Menu, tray, Icon, Scan Document Templates, shell32.dll, 172
Menu, tray, Add,
Menu, tray, Add, Exit, SaveSettings
Menu, tray, Add, Exit, ExitSettings
Try
Menu, tray, Icon, Exit, shell32.dll, 132

Expand Down Expand Up @@ -124,13 +124,13 @@ FileCopy, %F4ConfigFile%, %F4ConfigFile%.bak, 1
If (MatchList.settings.TCStart = 2) and !WinExist("ahk_class TTOTAL_CMD")
{
If FileExist(MatchList.settings.TCPath)
Run % MatchList.settings.TCPath ; %
Run % MatchList.settings.TCPath,,,TCOutputVarPID ; %
}

If (MatchList.settings.TCStart = 3)
{
If FileExist(MatchList.settings.TCPath)
Run % MatchList.settings.TCPath ; %
Run % MatchList.settings.TCPath,,,TCOutputVarPID ; %
}

; shared with F4MM
Expand All @@ -146,27 +146,38 @@ Gosub, GetAllExtensions
HotKeyState:="On"
Gosub, SetHotkeys

; Save Matchlist Object to XML
OnExit, SaveSettings
; Clear tmp file(s)
OnExit, ExitSettings

; End of Auto-execute section
If (Matchlist.settings.F4MMClose = 1)
If (Matchlist.settings.F4MMCloseAll = 1)
{
WinWaitClose, ahk_class TTOTAL_CMD
ExitApp
}
Else If (Matchlist.settings.F4MMClosePID = 1)
{
Sleep 5000
WinWaitClose, ahk_pid %TCOutputVarPID%
ExitApp
}
Return

Process:
ProcessFiles(MatchList)
MatchList.Temp.Files:="",MatchList.Temp.SelectedExtensions:="",MatchList.Delete("Temp")
Return

; Function executed by background hotkey (open directly)
ProcessFiles(MatchList, SelectedEditor = "-1")
{
Done:=[]
Stop:=0
Files:=GetFiles() ; Get list of selected files in TC, one per line
If (MatchList.Temp.Files = "")
Files:=GetFiles() ; Get list of selected files in TC, one per line
else
Files:=MatchList.Temp.Files
MatchList.Temp.Files:=""
; Check if we possibly have selected file(s) from an archive
If RegExMatch(Files,"iUm)" ArchiveExtentions )
{
Expand All @@ -176,7 +187,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
Check:=Files
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
SendMessage 1075, 904, 0, , ahk_class TTOTAL_CMD
SendMessage 1075, 904, 0, , ahk_class TTOTAL_CMD ; Edit (Notepad)
Return
}
}
Expand All @@ -199,7 +210,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
Break
open:=A_LoopField
SplitPath, A_LoopField, , , OutExtension

for k, v in MatchList
{
Index:=A_Index
Expand Down Expand Up @@ -259,11 +270,25 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
}
}
}
PostMessage 1075, 524, 0, , ahk_class TTOTAL_CMD ; Unselect all (files+folders)
}

; Get a list of extensions from selected files we can use to build filtered menu
GetExt(Files)
{
Global MatchList
Loop, parse, files, `n, `r
{
SplitPath, A_LoopField,,, OutExtension
Ext .= OutExtension "|"
}
MatchList.Temp["SelectedExtensions"]:=Trim(Ext,"|")
}

; Get a list of selected files using internal TC commands (see totalcmd.inc for references)
GetFiles()
{
Global MatchList
If WinActive("ahk_class TLister")
{
WinGetActiveTitle, Files
Expand All @@ -285,7 +310,8 @@ GetFiles()
Files:=Clipboard
Clipboard:=ClipboardSave
ClipboardSave:=""
PostMessage 1075, 524, 0, , ahk_class TTOTAL_CMD ; Unselect all (files+folders)
; PostMessage 1075, 524, 0, , ahk_class TTOTAL_CMD ; Unselect all (files+folders)
MatchList.Temp["Files"]:=Files
Return Files
}

Expand Down Expand Up @@ -400,7 +426,7 @@ GetInput(byref parameters, byref file, byref startdir, byref execute, program)
; %f41 placeholder to alter position of filenames on the command line.
;
if InStr(parameters,"%f41")
{
{
parameters:=StrReplace(parameters, "%f41", file)
file:=""
}
Expand All @@ -417,9 +443,9 @@ GetInput(byref parameters, byref file, byref startdir, byref execute, program)
{
Gui, AskInput:Add, Text, xp y5 , Command line parameters:
Gui, AskInput:Add, Edit, xp yp+20 w400 h20 , %parameters%
}
}
if (AskParameters <> 1) and (parameters <> "")
{
{
Gui, AskInput:Add, Text, xp y58 , Command line parameters:
Gui, AskInput:Add, Edit, xp yp+20 w400 h20 ReadOnly , %parameters%
}
Expand Down Expand Up @@ -559,26 +585,35 @@ If (InStr(BGHKey,"ESC"))
Hotkey, % hk_prefix . BGHKey, Process, %HotKeyState% ; %
; MsgBox % "OpenItDirectly: " hk_prefix . BGHKey ; debug

If (MatchList.settings.FilteredHotkey <> "ERROR") and (MatchList.settings.FilteredHotkey <> "")
{
hk_prefix:="$"
TMHKey:=MatchList.settings.FilteredHotkey
StringReplace, TMHKey, TMHKey, &amp`;amp`;, & , All
StringReplace, TMHKey, TMHKey, &amp`;, &, All
If (InStr(TMHKey,"ESC"))
hk_prefix:="~"

Hotkey, % hk_prefix . TMHKey, FilteredMenu, %HotKeyState% ; %
}

Hotkey, IfWinActive
Return

SaveSettings:
Gosub, SaveSetup
ExitApp
MatchList.Temp.Files:="",MatchList.Temp.SelectedExtensions:="",MatchList.Delete("Temp")
%F4Save%("MatchList", F4ConfigFile)
FileDelete, % TmpFileList
Return

SaveSetup:
If (A_ExitReason <> "Exit") ; to prevent saving it twice
{
if (MatchListStart <> MatchList) ; only save changes no need to save settings otherwise
%F4Save%("MatchList", F4ConfigFile)
}
ExitSettings:
FileDelete, % TmpFileList
If (Error = 1)
If (Error = 1) ; we can't read settings so create a new clean version
{
FileDelete, %F4ConfigFile%
Gosub, CreateNewConfig
}
ExitApp
Return


Expand Down Expand Up @@ -612,11 +647,14 @@ FileAppend,
<Invalid_Name id="settings" ahk="True">
<BackgroundHotkey>F4</BackgroundHotkey>
<ForegroundHotkey>Esc & F4</ForegroundHotkey>
<FilteredHotkey></FilteredHotkey>
<MaxFiles>30</MaxFiles>
<MenuPos>3</MenuPos>
<F4MMClose>0</F4MMClose>
<TCPath>c:\totalcmd\TotalCmd.exe</TCPath>
<TCStart>1</TCStart>
<F4MMCloseAll>0</F4MMCloseAll>
<F4MMClosePID>0</F4MMClosePID>
<FullMenu>z</FullMenu>
</Invalid_Name>
<Invalid_Name id="1" ahk="True">
<Exe>c:\WINDOWS\notepad.exe</Exe>
Expand All @@ -635,18 +673,21 @@ FileAppend,
[settings]
BackgroundHotkey=F4
ForegroundHotkey=Esc & F4
FilteredHotkey=
MaxFiles=30
MenuPos=3
TCPath=c:\totalcmd\TotalCmd.exe
TCStart=1
F4MMClose=0
F4MMCloseAll=0
F4MMClosePID=0
FullMenu=z
[1]
delay=0
exe=c:\WINDOWS\notepad.exe
ext=txt,xml
method=Normal
windowmode=1
), F4MiniMenu.ini
), F4MiniMenu.ini, UTF-16
}
Return

Expand All @@ -655,21 +696,26 @@ Return
DocumentTemplatesScan:
If (FileExist(A_ScriptDir "\DocumentTemplates\") = "D")
{
templatesExtBeforeScan:=MatchList.Settings["templatesExt"]
Loop, %A_ScriptDir%\DocumentTemplates\template.*
{
SplitPath, A_LoopFileName, , , TemplatesOutExtension
templatesExt .= TemplatesOutExtension ","
}
MatchList.Settings["templatesExt"]:=Trim(templatesExt,",")
TemplatesOutExtension:=""
templatesExt:=""
%F4Save%("MatchList", F4ConfigFile)
; only update when its has been changed
If (templatesExtBeforeScan <> Trim(templatesExt,","))
{
MatchList.Settings["templatesExt"]:=Trim(templatesExt,",")
%F4Save%("MatchList", F4ConfigFile)
}
templatesExt:="",TemplatesOutExtension:="",templatesExtBeforeScan:=""
}
Return

; Includes

#include %A_ScriptDir%\inc\Menu.ahk
#include %A_ScriptDir%\inc\FilteredMenu.ahk
#include %A_ScriptDir%\inc\Settings.ahk
#include %A_ScriptDir%\inc\Editors.ahk
#include %A_ScriptDir%\inc\HelperFunctions.ahk ; shared with F4TCIE
Expand Down
6 changes: 6 additions & 0 deletions F4TCIE.ahk
Expand Up @@ -26,6 +26,12 @@ Templates : Create a DocumentTemplates\ folder and place files for each templa
#NoTrayIcon
#NoEnv

; <for compiled scripts>
;@Ahk2Exe-SetDescription F4MiniMenu: Open files from TC
;@Ahk2Exe-SetVersion 0.97.0.0
;@Ahk2Exe-SetCopyright MIT License - Copyright (c) https://github.com/hi5
; </for compiled scripts>

SetWorkingDir, %A_ScriptDir%

File=%1% ; cmd line parameter "%1" it receives from TC
Expand Down
10 changes: 8 additions & 2 deletions changelog.md
@@ -1,5 +1,11 @@
## Changelog

* 20190622 - v0.97
a) New option for filtered foreground menu: only show programs that match selected extensions. See Settings for setup. https://github.com/hi5/F4MiniMenu/issues/21
b) Fix: correctly use %commander_path% in Editor listview IL_Add routine (if v.Icon isn't set)
c) Fix: Editor - Set as Default should now work correctly
d) Fix: Editor - cancel should now work more reliably by using .clone()
e) Only save settings when actually changing them e.g. no longer at each start/exit of the script
* 20190607 - v0.96.2 - Fix: adding Try to all Menu, tray, icons to avoid startup error for compiled scripts and autohotkey.exe is not installed. https://www.ghisler.ch/board/viewtopic.php?p=356022#p356022
* 20190606 - v0.96.1 - Fix: adding close F4MiniMenu setting to INI version (iob.ahk) https://www.ghisler.ch/board/viewtopic.php?p=355998#p355998
* 20190527 - v0.96
Expand All @@ -18,7 +24,7 @@
d) Now use %TEMP%\$$f4mtmplist$$.m3u instead of ScriptFolder - [requested by Ovg](http://ghisler.ch/board/viewtopic.php?p=319773&sid=2e2472aec32f6906e699d095b4998ea3#319773)
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.
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
Expand All @@ -36,7 +42,7 @@
* 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](#filelist) method;
c) Removed "Open Mode".
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.
Expand Down

0 comments on commit ca34aeb

Please sign in to comment.