Skip to content

Commit

Permalink
v1.47 resizing of Configure Editors GUI; some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hi5 committed Feb 9, 2025
1 parent 25f85d7 commit 34d131e
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 25 deletions.
49 changes: 41 additions & 8 deletions F4MiniMenu.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Script : F4MiniMenu.ahk for Total Commander - AutoHotkey 1.1+ (Ansi and Unicode)
Version : v1.46
Version : v1.47
Author : hi5
Last update : 09 February 2025
Purpose : Minimalistic clone of the F4 Menu program for Total Commander (open selected files in editor(s))
Expand All @@ -20,10 +20,10 @@ SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode, 2
; Setup variables, menu, hotkeys etc

F4Version:="v1.46"
F4Version:="v1.47"

; <for compiled scripts>
;@Ahk2Exe-SetFileVersion 1.46
;@Ahk2Exe-SetFileVersion 1.47
;@Ahk2Exe-SetProductName F4MiniMenu
;@Ahk2Exe-SetDescription F4MiniMenu: Open files from TC
;@Ahk2Exe-SetProductVersion Compiled with AutoHotkey v%A_AhkVersion%
Expand Down Expand Up @@ -373,7 +373,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
cmdfiles .= """" A_LoopField """" A_Space ; " fix highlighting
OpenFile(v, cmdfiles, MatchList.Settings.MaxWinWaitSec)
If MatchList.Settings.log
Log(A_Now " : cmdline -> " v.exe "|" cmdfiles "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
Log(A_Now " : ProcessFiles, cmdline -> " v.exe "|" cmdfiles "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
cmdfiles:=""
}
else If (v.Method = "FileList")
Expand All @@ -382,7 +382,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
FileAppend, %list%, %TmpFileList%, UTF-8-RAW
OpenFile(v, TmpFileList, MatchList.Settings.MaxWinWaitSec)
If MatchList.Settings.log
Log(A_Now " : FileList -> " v.exe "|" TmpFileList "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
Log(A_Now " : ProcessFiles, FileList -> " v.exe "|" TmpFileList "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
}
Else If (v.Method <> "Files")
{
Expand All @@ -392,7 +392,7 @@ ProcessFiles(MatchList, SelectedEditor = "-1")
Continue
OpenFile(v, A_LoopField, MatchList.Settings.MaxWinWaitSec)
If MatchList.Settings.log
Log("`n" A_Now " : Files -> " v.exe "|" A_LoopField "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
Log("`n" A_Now " : ProcessFiles, Files -> " v.exe "|" A_LoopField "|" MatchList.Settings.MaxWinWaitSec,MatchList.Settings.logFile)
}
}
}
Expand Down Expand Up @@ -421,41 +421,53 @@ GetFiles()
{
FileRead, Files, %CLI_File%
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, CLI_Exit ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

If MatchList.settings.Explorer and Explorer_Active()
{
Files:=Explorer_GetSelection()
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, Explorer ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

If MatchList.settings.Everything and Everything_Active()
{
Files:=Everything_GetSelection()
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, Everything ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

If MatchList.settings.DoubleCommander and DoubleCommander_Active()
{
Files:=DoubleCommander_GetSelection()
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, DoubleCommander ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

If MatchList.settings.XYPlorer and XYPlorer_Active()
{
Files:=XYPlorer_GetSelection()
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, XYPlorer ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

If MatchList.settings.QDir and QDir_Active()
{
Files:=QDir_GetSelection()
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, QDir ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

Expand All @@ -469,6 +481,8 @@ GetFiles()
Files:=RegExReplace(Files,"U)^.*\[(.*).$","$1")
If ListerWindowClose in 2,3
WinClose, A
If MatchList.Settings.log
Log(A_Now " : GetFiles, Lister ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

Expand All @@ -478,6 +492,8 @@ GetFiles()
If (Files <> "")
{
RegExMatch(Files,"U) - \K\[(.*)\]`r?`n",Files)
If MatchList.Settings.log
Log(A_Now " : GetFiles, QuickView ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files1
}
}
Expand All @@ -489,7 +505,11 @@ GetFiles()
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
Return Files
{
If MatchList.Settings.log
Log(A_Now " : GetFiles, Find files ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}
}

ClipboardSave:=ClipboardAll
Expand All @@ -501,6 +521,8 @@ GetFiles()
ClipboardSave:=""
; PostMessage 1075, 524, 0, , ahk_class TTOTAL_CMD ; Unselect all (files+folders)
MatchList.Temp["Files"]:=Files
If MatchList.Settings.log
Log(A_Now " : GetFiles, TC File Panel ->`n" Files "`n-----------------------",MatchList.Settings.logFile)
Return Files
}

Expand Down Expand Up @@ -981,10 +1003,17 @@ if (A_PriorHotkey <> "$Esc" or A_TimeSincePriorHotkey > 400)
Return
}
Else
WinClose ahk_exe everything.exe
{
WinClose ahk_exe everything.exe
WinClose ahk_exe everything64.exe
}
Return
#If

/*
; use *Enter to open folders in TC panels, disable for now 20250209
#If MatchList.settings.Everything and Everything_Active()
Enter:: ; open in source panel/tab
Expand Down Expand Up @@ -1016,12 +1045,15 @@ Return
TCCD(tc,par,dir)
{
WinClose ahk_exe everything.exe
WinClose ahk_exe everything64.exe
If !InStr(par,"/R=")
Run, %tc% %par% "%dir%\"
Else
Run, %tc% %par%"%dir%\"
}
*/

SaveSettings:
MatchList.Temp.Files:="",MatchList.Temp.SelectedExtensions:="",MatchList.Delete("Temp")
%F4Save%("MatchList", F4ConfigFile)
Expand Down Expand Up @@ -1171,6 +1203,7 @@ Return
#include %A_ScriptDir%\lib\dpi.ahk
#include %A_ScriptDir%\lib\tc.ahk ; wm_copydata
#include %A_ScriptDir%\lib\log.ahk
#include %A_ScriptDir%\lib\AutoXYWH.ahk

;@Ahk2Exe-IgnoreBegin
#include *i %A_ScriptDir%\..\ButtonBarKeyboard\ButtonBarKeyboard.ahk
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

* 20250209 - v1.47 a) Allow resizing of Configure Editors GUI (browse list) using AutoXYWH()
b) Some code cleanup re Enter shortcuts; add everything64.exe to Esc Winclose routine
c) Trace menu steps and result of GetFiles in log

* 20250209 - v1.46 a) Finetuning Everything_GetSelection() to check for selected rows in listview (if none get first result only)

* 20250208 - v1.45 a) Finetuning Everything_Active() (using "A" not "Everything" in WinGet to detect active window)
Expand Down
4 changes: 3 additions & 1 deletion inc/CLIParser.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ If (A_Args.Length() <> 0)
CLI_Settings:=1
if (v = "/ED")
CLI_Editors:=1
}
}
If MatchList.Settings.log
Log(A_Now " : CLI Params -> CLI_ShowMenu: " CLI_ShowMenu " CLI_FilteredMenu: " CLI_FilteredMenu "CLI_Settings: " CLI_Settings " CLI_Editors: " CLI_Editors,MatchList.Settings.logFile)
}
42 changes: 31 additions & 11 deletions inc/Editors.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Important:

Info:
1 - Delay (in miliseconds) D&&D = Drag && Drop, Open = startup.
2 - Sort using Ctrl+UP / Ctrl+DOWN or use Edit menu (multiple rows possible).
2 - Sort using Ctrl+UP / Ctrl+DOWN or use Edit menu
(multiple rows possible).
)

IfWinExist, F4MiniMenu - Editor Settings ahk_class AutoHotkeyGUI
Expand All @@ -39,6 +40,8 @@ IfWinExist, F4MiniMenu - Editor Settings ahk_class AutoHotkeyGUI
Return
}

Gui, Browse: +Resize +MinSize790x427

Menu, EditMenu, Add, Move Up`tCtrl+Up, MoveUp
Menu, EditMenu, Add, Move Down`tCtrl+Down, MoveDown
Menu, MenuBar, Add, %A_Space%Edit, :EditMenu
Expand All @@ -47,21 +50,38 @@ Gui, Browse:Menu, MenuBar
; INI Gui
Gui, Browse:font, % dpi("s8")
Gui, Browse:Add, ListView, % dpi("x6 y5 w780 h285 grid hwndhLV vLV gLVLabel"), Program|Parameters|Start Dir.|Window|Extensions|Method|D&D|Open|Editor|Icon|Name
Gui, Browse:Add, GroupBox, % dpi("x6 yp+290 w360 h120 vGroupBoxInfo"), Comments
Gui, Browse:Add, Text, % dpi("x16 yp+20 w340"), %infotext%
Gui, Browse:Add, Button, % dpi("xp+370 yp w70 h24 gSettings"), &Settings
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gAdd"), &Add
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gModify"), &Modify
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gRemove"), &Remove
Gui, Browse:Add, Button, % dpi("xp-240 yp+40 w150 h24 gOK"), &OK
Gui, Browse:Add, Button, % dpi("xp+160 yp w150 h24 gCancel"), &Cancel
Gui, Browse:Add, Link, % dpi("xp-160 yp+40 w310 h16"), F4MiniMenu %F4Version% -- More info at <a href="https://github.com/hi5/F4MiniMenu">Github.com/hi5/F4MiniMenu</a>
Gui, Browse:Add, GroupBox, % dpi("x6 yp+290 w390 h120 vGroupBoxInfo"), Comments
Gui, Browse:Add, Text, % dpi("x16 yp+20 w340 vInfoText"), %infotext%
Gui, Browse:Add, Button, % dpi("xp+445 yp w70 h24 gSettings vButtonSettings"), &Settings
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gAdd vButtonAdd"), &Add
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gModify vButtonModify"), &Modify
Gui, Browse:Add, Button, % dpi("xp+80 yp w70 h24 gRemove vButtonRemove"), &Remove
Gui, Browse:Add, Button, % dpi("xp-240 yp+40 w150 h24 gOK vButtonOK"), &OK
Gui, Browse:Add, Button, % dpi("xp+160 yp w150 h24 gCancel vButtonCancel"), &Cancel
Gui, Browse:Add, Link, % dpi("xp-160 yp+40 w310 h16 vLinkText"), F4MiniMenu %F4Version% -- More info at <a href="https://github.com/hi5/F4MiniMenu">Github.com/hi5/F4MiniMenu</a>
Gosub, UpdateListview
LvHandle := New LV_Rows(hLV)
Gui, Browse:Show, % dpi("x261 y211 h427 w790 center"), F4MiniMenu - Editor Settings

Sleep 100

BrowseGuiSize:
If (A_EventInfo = 1) ; The window has been minimized.
Return
AutoXYWH("w h" , "Lv")
AutoXYWH("y" , "GroupBoxInfo")
AutoXYWH("y" , "InfoText")
AutoXYWH("x y" , "ButtonSettings")
AutoXYWH("x y" , "ButtonAdd")
AutoXYWH("x y" , "ButtonModify")
AutoXYWH("x y" , "ButtonRemove")
AutoXYWH("x y" , "ButtonOK")
AutoXYWH("x y" , "ButtonCancel")
AutoXYWH("x y" , "LinkText")
ControlGetPos, , , OutWidth, , Syslistview321, F4MiniMenu - Editor Settings
LV_ModifyCol(1, (dpifactor*250) + (OutWidth-780))
Return

NewEditor:
If (New = 1) ; we choose "Add new Editor in foreground menu"
{
Expand Down Expand Up @@ -136,7 +156,7 @@ SelItem := LV_GetNext()
If (SelItem = 0)
SelItem = 1
LV_GetText(Ask, SelItem, 1)
MsgBox, 52, Remove editor (only one entry per time), Do you want to remove:`n%Ask%?
MsgBox, 52, Remove editor (one entry),Do you want to remove:`n%Ask%?
IfMsgBox, Yes
{
LV_Delete(SelItem)
Expand Down
10 changes: 9 additions & 1 deletion inc/Menu.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Return
; Tray menu
MenuHandler:
; MsgBox % A_ThisMenu ":" A_ThisMenuItemPos-1 ":" MatchList[A_ThisMenuItemPos-1].exe ; debug
If MatchList.Settings.log
Log(A_Now " : Menuhandler, call -> A_ThisMenu=" A_ThisMenu "| A_ThisMenuItemPos-1=" A_ThisMenuItemPos-1 "| Exe=" A_ThisMenuItem,MatchList.Settings.logFile)

; Easy & Quick options first
If (A_ThisMenuItem = "&Open")
Expand Down Expand Up @@ -82,25 +84,31 @@ Else If (A_ThisMenuItem = "&Pause Script")
Return
}
Else If (A_ThisMenuItem = " Exit")
Return
Return
Else If (A_ThisMenuItem = " Settings") ; Settings menu
{
Gosub, Settings
Return
}
Else If (A_ThisMenuItemPos = 1) ; Default editor
{
If MatchList.Settings.log
Log(A_Now " : Menuhandler, selected editor -> Default editor" ,MatchList.Settings.logFile)
ProcessFiles(Matchlist, 1)
Return
}
Else
If (MatchList.Temp.SelectedExtensions = "") or (A_ThisMenu = "MyMenu") ; entire Foreground menu
{
If MatchList.Settings.log
Log(A_Now " : Menuhandler, selected editor -> editor from entire menu, Exe=" A_ThisMenuItem,MatchList.Settings.logFile)
ProcessFiles(Matchlist, A_ThisMenuItemPos-1) ; proceed with the selected editor. Menu order = editor order.
MatchList.Temp.Files:="",MatchList.Temp.SelectedExtensions:="",MatchList.Delete("Temp"),MatchListReference:=""
}
else ; filtered Foreground menu
{
If MatchList.Settings.log
Log(A_Now " : Menuhandler, selected editor -> editor from filtered menu, Exe=" A_ThisMenuItem,MatchList.Settings.logFile)
ProcessFiles(Matchlist, MatchListReference[A_ThisMenuItemPos])
MatchList.Temp.Files:="",MatchList.Temp.SelectedExtensions:="",MatchList.Delete("Temp"),MatchListReference:=""
}
Expand Down
1 change: 0 additions & 1 deletion inc/Settings.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ When unchecked all selected files will be opened even when QuickView is being us

)


;Ev DirTree:`tReplace TC Dir Tree (Alt-F10)`n
;Ev Path:`t`tPath to eEverything.exe (required by DirTree)`n`n
Return
41 changes: 41 additions & 0 deletions lib/AutoXYWH.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; =================================================================================
; Function: AutoXYWH
; Move and resize control automatically when GUI resizes.
; Parameters:
; DimSize - Can be one or more of x/y/w/h optional followed by a fraction
; add a '*' to DimSize to 'MoveDraw' the controls rather then just 'Move', this is recommended for Groupboxes
; cList - variadic list of ControlIDs
; ControlID can be a control HWND, associated variable name, ClassNN or displayed text.
; The later (displayed text) is possible but not recommend since not very reliable
; Examples:
; AutoXYWH("xy", "Btn1", "Btn2")
; AutoXYWH("w0.5 h 0.75", hEdit, "displayed text", "vLabel", "Button1")
; AutoXYWH("*w0.5 h 0.75", hGroupbox1, "GrbChoices")
; ---------------------------------------------------------------------------------
; Version: 2015-5-29 / Added 'reset' option (by tmplinshi)
; 2014-7-03 / toralf
; 2014-1-2 / tmplinshi
; requires AHK version : 1.1.13.01+
; =================================================================================
AutoXYWH(DimSize, cList*){ ; http://ahkscript.org/boards/viewtopic.php?t=1079
static cInfo := {}

If (DimSize = "reset")
Return cInfo := {}

For i, ctrl in cList {
ctrlID := A_Gui ":" ctrl
If ( cInfo[ctrlID].x = "" ){
GuiControlGet, i, %A_Gui%:Pos, %ctrl%
MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
fx := fy := fw := fh := 0
For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]")))
If !RegExMatch(DimSize, "i)" dim "\s*\K[\d.-]+", f%dim%)
f%dim% := 1
cInfo[ctrlID] := { x:ix, fx:fx, y:iy, fy:fy, w:iw, fw:fw, h:ih, fh:fh, gw:A_GuiWidth, gh:A_GuiHeight, a:a , m:MMD}
}Else If ( cInfo[ctrlID].a.1) {
dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw , dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
For i, dim in cInfo[ctrlID]["a"]
Options .= dim (dg%dim% * cInfo[ctrlID]["f" dim] + cInfo[ctrlID][dim]) A_Space
GuiControl, % A_Gui ":" cInfo[ctrlID].m , % ctrl, % Options
} } }
2 changes: 1 addition & 1 deletion lib/Everything.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Everything_DirectoryTree()
StartSearch:=StrReplace(StartSearch,"/drive",drive)
StartSearch:=StrReplace(StartSearch,"/dir",dir)
Run, % StartSearch
WinWaitActive, ahk_exe Everything.exe
WinWaitActive, ahk_exe Everything.exe ; note 20250209 everything64.exe v1.5 alpha
ControlSend, Edit1, {space}, ahk_exe Everything.exe
}
Expand Down
Loading

0 comments on commit 34d131e

Please sign in to comment.