From 34d131ef7b47bef92dd4e120032674ac249ce5b3 Mon Sep 17 00:00:00 2001 From: hi5 Date: Sun, 9 Feb 2025 22:05:29 +0100 Subject: [PATCH] v1.47 resizing of Configure Editors GUI; some code cleanup --- F4MiniMenu.ahk | 49 ++++++++++++++++++++++++++++++++++++++-------- changelog.md | 4 ++++ inc/CLIParser.ahk | 4 +++- inc/Editors.ahk | 42 ++++++++++++++++++++++++++++----------- inc/Menu.ahk | 10 +++++++++- inc/Settings.ahk | 1 - lib/AutoXYWH.ahk | 41 ++++++++++++++++++++++++++++++++++++++ lib/Everything.ahk | 2 +- readme.md | 5 +++-- 9 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 lib/AutoXYWH.ahk diff --git a/F4MiniMenu.ahk b/F4MiniMenu.ahk index 961638c..af529d9 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.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)) @@ -20,10 +20,10 @@ SetWorkingDir, %A_ScriptDir% SetTitleMatchMode, 2 ; Setup variables, menu, hotkeys etc -F4Version:="v1.46" +F4Version:="v1.47" ; -;@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% @@ -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") @@ -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") { @@ -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) } } } @@ -421,6 +421,8 @@ 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 } @@ -428,6 +430,8 @@ GetFiles() { Files:=Explorer_GetSelection() MatchList.Temp["Files"]:=Files + If MatchList.Settings.log + Log(A_Now " : GetFiles, Explorer ->`n" Files "`n-----------------------",MatchList.Settings.logFile) Return Files } @@ -435,6 +439,8 @@ GetFiles() { Files:=Everything_GetSelection() MatchList.Temp["Files"]:=Files + If MatchList.Settings.log + Log(A_Now " : GetFiles, Everything ->`n" Files "`n-----------------------",MatchList.Settings.logFile) Return Files } @@ -442,6 +448,8 @@ GetFiles() { Files:=DoubleCommander_GetSelection() MatchList.Temp["Files"]:=Files + If MatchList.Settings.log + Log(A_Now " : GetFiles, DoubleCommander ->`n" Files "`n-----------------------",MatchList.Settings.logFile) Return Files } @@ -449,6 +457,8 @@ GetFiles() { Files:=XYPlorer_GetSelection() MatchList.Temp["Files"]:=Files + If MatchList.Settings.log + Log(A_Now " : GetFiles, XYPlorer ->`n" Files "`n-----------------------",MatchList.Settings.logFile) Return Files } @@ -456,6 +466,8 @@ GetFiles() { Files:=QDir_GetSelection() MatchList.Temp["Files"]:=Files + If MatchList.Settings.log + Log(A_Now " : GetFiles, QDir ->`n" Files "`n-----------------------",MatchList.Settings.logFile) Return Files } @@ -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 } @@ -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 } } @@ -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 @@ -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 } @@ -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 @@ -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) @@ -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 diff --git a/changelog.md b/changelog.md index df35e51..e794b08 100644 --- a/changelog.md +++ b/changelog.md @@ -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) diff --git a/inc/CLIParser.ahk b/inc/CLIParser.ahk index 9882dc7..c81f673 100644 --- a/inc/CLIParser.ahk +++ b/inc/CLIParser.ahk @@ -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) } diff --git a/inc/Editors.ahk b/inc/Editors.ahk index c4e183d..9fa1f64 100644 --- a/inc/Editors.ahk +++ b/inc/Editors.ahk @@ -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 @@ -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 @@ -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 Github.com/hi5/F4MiniMenu +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 Github.com/hi5/F4MiniMenu 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" { @@ -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) diff --git a/inc/Menu.ahk b/inc/Menu.ahk index fd073e8..49f6980 100644 --- a/inc/Menu.ahk +++ b/inc/Menu.ahk @@ -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") @@ -82,7 +84,7 @@ Else If (A_ThisMenuItem = "&Pause Script") Return } Else If (A_ThisMenuItem = " Exit") - Return + Return Else If (A_ThisMenuItem = " Settings") ; Settings menu { Gosub, Settings @@ -90,17 +92,23 @@ Else If (A_ThisMenuItem = " Settings") ; Settings menu } 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:="" } diff --git a/inc/Settings.ahk b/inc/Settings.ahk index 7f7293e..d04390e 100644 --- a/inc/Settings.ahk +++ b/inc/Settings.ahk @@ -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 diff --git a/lib/AutoXYWH.ahk b/lib/AutoXYWH.ahk new file mode 100644 index 0000000..62f605d --- /dev/null +++ b/lib/AutoXYWH.ahk @@ -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 +} } } diff --git a/lib/Everything.ahk b/lib/Everything.ahk index 345a2ce..c2b587b 100644 --- a/lib/Everything.ahk +++ b/lib/Everything.ahk @@ -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 } diff --git a/readme.md b/readme.md index ebb7482..0f75545 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# F4MiniMenu - v1.46 +# F4MiniMenu - v1.47 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)). @@ -343,7 +343,7 @@ To configure Total Commander to use F4TCIE.ahk: TC, Configuration, Edit/View, Editor (ini): drive:\path-to\F4TCIEi.ahk "%1" -Note: if both AutoHotkey v1.1 and v2 are installed you may receive an error message (from the AutoHotkey launcher). +Note: if both AutoHotkey v1.1 and v2 are installed an error message may be shown (from the AutoHotkey launcher). In that case include the full path of the AutoHotkey v1.1 executable before the drive:\path-to\F4TCIE.ahk like so: TC, Configuration, Edit/View, Editor: @@ -511,6 +511,7 @@ __Editor configuration__ * [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 +* [AutoXYWH() - toralf and tmplinshi](https://www.autohotkey.com/boards/viewtopic.php?t=1079) ## Changelog