F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
dindog
Senior Member
Senior Member
Posts: 315
Joined: 2010-10-18, 07:41 UTC

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *dindog »

hi5 wrote: 2019-10-19, 07:38 UTC Some thoughts:
* Perhaps AutoCAD is running as administrator (and in that case F4mm should also run as admin I think)
* Perhaps AutoCAD isn't running yet and/or the files are dropped to quickly, you can try and play with the D&D and Open delays (in milliseconds)
2.1 Drag & Drop delay gives program to start up before trying to drop the files - you may need to apply trail and error.
2.2 Open delay, pauses X ms to open next file.
Possibly: Quick search shows you're not the only one it seems with that request :) Some people use a launcher (I don't know anything about your version of course)

https://forums.autodesk.com/t5/autocad-forum/open-multiple-drawings-using-one-autocad-window-only-in-windows/td-p/3083076/page/2
https://github.com/vanowm/AutoCAD2000-2002_Launcher (perhaps use this as "editor" in F4mm)
I do a little research last night by the links you post above, and I can have drag and drop for autocad only by its main windows class by ahk_class, at least for the first files.. then I can drop with ahk_exe, weird. Anyway, it's not practicle have a global drag&drop for Autocad, because it's very hard to know how long a file cad need to load,it will vary from 0.x second to half a minute, and before the last filed was completely loaded, it won't accept new drop in.

One more things, I noticed the non-ASCII name file fail to drop, is there something of the filename string converted to before it drop to the application?
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *hi5 »

So you might be able to produce a small launcher yourself using method 3 (filelist) and process these one by one via dropfiles ahk_class. If there is a way to see when a file has completed loading - perhaps a statusbar or checking the window title? - build in a "wait for file to be loaded" check before moving t the next.

With regards to non-ASCII name files: I don't really know why/how to fix that - when I check with some MsgBox-es I see the filenames are passed correctly from TC to F4mm to the DragDrop function but the application receives "garbage" it seems. When actually manually dragging that same file some apps accept such files, but others still can't "read" it even though the app supports drag & drop. I've tried quite a few dropfiles functions posted on the AHK forum but they all have that "error" :(
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
dindog
Senior Member
Senior Member
Posts: 315
Joined: 2010-10-18, 07:41 UTC

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *dindog »

Yes, I had written a drag & drop wrapper for F4menu by the drop function code in F4mm, but found that the current drop function do not support non-ascii filename is frusatrated to me, cause half-of my documents filename is in Chinese. I've posted a thread in the ahk forum, hoping someone will have answer of that. I remember I'd read in somewhere that the filename should convert to UTF-8 or unicode or somethings when dropping last night. Can't find it out again... :(
User avatar
dindog
Senior Member
Senior Member
Posts: 315
Joined: 2010-10-18, 07:41 UTC

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *dindog »

hi5 wrote: 2019-10-20, 12:20 UTC So you might be able to produce a small launcher yourself using method 3 (filelist) and process these one by one via dropfiles ahk_class. If there is a way to see when a file has completed loading - perhaps a statusbar or checking the window title? - build in a "wait for file to be loaded" check before moving t the next.

With regards to non-ASCII name files: I don't really know why/how to fix that - when I check with some MsgBox-es I see the filenames are passed correctly from TC to F4mm to the DragDrop function but the application receives "garbage" it seems. When actually manually dragging that same file some apps accept such files, but others still can't "read" it even though the app supports drag & drop. I've tried quite a few dropfiles functions posted on the AHK forum but they all have that "error" :(
I've found an code snippet which supported non-ascii drag & drop. tested, worked. Sorry I didn't remember from which thread in AHK forum I found it.

Code: Select all

DropFiles( FileList, wTitle="", Ctrl="", X=0, Y=0, NCA=0 ) 
{
 characterSize := A_IsUnicode ? 2 : 1
 StringReplace, FileList, FileList, `r`n, `n , All
 VarSetCapacity( DROPFILES,20,32 ),  DROPFILES.=FileList "`n`n",  nSize:=StrLen(DROPFILES)*characterSize
 StringReplace, DROPFILES,DROPFILES, `n,`n, UseErrorLevel
 Loop %ErrorLevel%
	NumPut( 0, DROPFILES, InStr(DROPFILES,"`n",0,0)*characterSize - characterSize, A_IsUnicode ? "Short" : "Char" )

 pDP := &DROPFILES
 NumPut(20, pDP+0)
 NumPut(X, pDP+4)
 NumPut(Y, pDP+8)
 NumPut(NCA, pDP+12)
 NumPut(A_IsUnicode ? 1 : 0, pDP+16)
 hDrop := DllCall( "GlobalAlloc", UInt,0x42, UInt, nSize )
 pData := DllCall( "GlobalLock", UInt, hDrop)
 DllCall( "RtlMoveMemory", UInt,pData, UInt,pDP, UInt, nSize )
 DllCall( "GlobalUnlock", UInt,hDrop )
 PostMessage, 0x233, hDrop, 0, %Ctrl%, %wTitle% ; WM_DROPFILES := 0x233
}
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *hi5 »

That code doesn't work correctly (at all) for me on Win 10/64bit and AutoHotkey 64bit - it does work better when I use the 32bit unicode version of AHK. Strange.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
dindog
Senior Member
Senior Member
Posts: 315
Joined: 2010-10-18, 07:41 UTC

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *dindog »

hi5 wrote: 2019-11-01, 22:23 UTC That code doesn't work correctly (at all) for me on Win 10/64bit and AutoHotkey 64bit - it does work better when I use the 32bit unicode version of AHK. Strange.
I am using win10 64bit, both ahk 64 & 32 works.. I have my own D&D wrapper for F4menu now which support non-ASCII characters using the above code snippet, strange.
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline

Post by *hi5 »

v1.00 @ https://github.com/hi5/F4MiniMenu
  • Rudimentary support for Windows Explorer, Double Commander, XYPlorer, and Everything (see settings and https://github.com/hi5/F4MiniMenu#other-programs)
  • Passive mode using parameters to use F4MiniMenu via Button bar, Start Menu, or F4 Editor (start F4MM, processes files, close F4MM, so not a persistent script) - https://github.com/hi5/F4MiniMenu#passive
  • Fix: Path from Lister Windows Title failed if file name started/ended with [ or ] characters e.g. "[2000] My Document.txt"
  • Fix: "Start Total Commander if not running" feature #23 https://github.com/hi5/F4MiniMenu/issues/23
  • Fix: Use another method to calculate Y for Position = 2 in GetPos); other minor changes
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *AntonyD »

2hi5
1) Error:
I want to use INI configuration file so I renamed F4MiniMenu-64.exe to F4MiniMenu-64i.exe
After start this file I've got proper (for the first sight) INI file. I started to fill Editors, click OK,
looks like I proper saved all. And decided to relaunch this script from corresponding cont.menu
item in order to make sure that all editors will be applied correctly for proper file extensions..
And I got this:
[img]https://i.ibb.co/hMtfwjq/2022-10-30-124003.png[/img]
I tried again and again - no luck. I tried to open Settings - the same.
After kill process - restart main process (F4MiniMenu-64i.exe) - looks like my problem is gone.

2) Error
When I tried to edit one record among editors after I click Modify button I've got this:
[img]https://i.ibb.co/z2XDn1x/2022-10-30-124003.png[/img]

+ suggestion - IMHO double click on any records definitely by default should open this record in Modify'ing window.

3) Bug?
Element "Window" with options 1/2/3(Normal/Maximized/Minimized) looks like not always work?
https://github.com/microsoft/XmlNotepad
tried to call this tool with option 2 for editing of XML files and always just got a window in the standard size.

4)There is one question/suggestion.
Now the notion of a default editor is quite blurry - sort of like it's just "the first one in the list among others".
BUT I would like to see more detail on its role and purpose very much.
So, the point is that selecting a default editor and calling it for files should always be distinguishable from using other editors.
Namely, its assignment must be done in a separate settings GUI-item. And when specifying it, it should not require selecting the extensions for which it should be called at all! Because it's our fail-safe editor! Whereas for all other editors, assignment/binding to a specific file extension should be an important and mandatory item!

That is why its setup should be performed directly in the utility "Settings" window, and in the "Configure editors" window - it is necessary only to create a chain of dependencies "extension(-s) => editor".

5) Another suggestion.
In the menu of editors (full or filtered - it does not matter) - should not show right away their names (even if I can set these names myself) - but showing the correlation "extension -> editor". Therefore, a more important and visible representation of this menu should be: List extensions alphabetically as main menu items. And when you expand these items - there is a display/selection of the editors assigned to the extension in the form of additional sub-items. YES, it may happen that we actually see editor X more than once - for several extensions (in different menu sub-items). But that's okay in this case.
When we look through all the Editors options or want to add a new editor, it is important for us to understand for which extensions we ALREADY have an entry, isn't it? After all, you may want to open the same simple VBS file, either notepad.exe or very-special-tool.exe. And to see in the general menu just the entries of the available editors in the form:
notepad.exe
very-special-tool.exe
does not add insight into of which files they are intended to open.

6) Suggestions. What about LANGuage pack? Definitely such wonderful tool should be able to communicate with users on their mother-language:)

7) Suggestion: Update all screenshots on github))
#146217 personal license
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *AntonyD »

[img]https://i.ibb.co/Bg2hh0Z/2022-10-31-132013.png[/img]
I try to setup the tool from scratch - and with chosen options on above left pic - I can't press OK,
I am getting the error dlg mentioned on the right side....
Btw why hotkeys options are radio buttons? I can set - but I can't unset it! Yep, there is the button Clear Hotkeys
but it works for all 3 options - whereas I want to change only one!

One more thing. There are some editors/viewers - who have the option: always be in one copy.
And when I try to open 5 files by this editor at once with this utility, the first thing I see is a message
that more than one instance of program/editor X cannot be run on the system....
IMHO When you try to open multiple files at once, you should
1) Call ONE editor and pass it at command line parameters list of all selected files at once.
2) invoke each subsequent instance of the editor after a pause of 2 seconds. During this time,
the first running instance will be able to intercept the processing of the subsequent file, and
not give a message that it is forbidden to run two or more instances of this program.

Of course, option 1 is the most logical and preferable.
#146217 personal license
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *hi5 »

Compiled pre-release only https://github.com/hi5/F4MiniMenu/releases/tag/v1.1

This should take care of (most) reported issues:
a) Fix: try to catch all empty hotkeys to avoid errors at startup
b) Change: double click on an "editor" opens modify window
c) Change: Settings - replace Radio controls for Esc/Win with DropDownLists (not thoroughly tested)
d) Fix: WinMaximize and Sleep function should work better (again)
e) Fix: additional check to prevent Modify Gui throwing "The same variable cannot be used for more than one control" error
f) New: TRY, catch -> revert to standard editor if defined editor can not be found, show notification using OSDTIP_Pop()

Default editor:
The first editor in the list is the default editor. The "flow" is:

Open the file in the first editor that matches the EXT, if EXT not found, use default editor. And the default editor needs extensions as otherwise it would open the first editor for say TXT files but I WANT to open it in the default editor which is why you should define them for the default editor as well.

As I tend to swap from default editor during testing something (beta tester for some programs) I will keep it as is. It is just so easy to move the editor(s) around by making the beta the first entry.

If I move the default editor to another section / settings screen - I would find it to be too much of a hassle and I'm guessing for most it is "set and forget" anyway.

Language:
The Gui only has a few buttons which are hardly worth translating, the https://github.com/hi5/F4MiniMenu/blob/master/readme.md would make more sense but Google (or other) translate does a decent job I expect.

Meny by Ext:
I don't think I'll do this it would mean more actions to open the desired program because you need to expand the _ext_ menu to get to the editor you want.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *AntonyD »

Window "Editor Configuration" does not close by pressing Esc.
After first try to open some file with corresponding editor by F4 - and all other attempts will fail.
F4 does nothing from this moment. Completely nothing...
The same and for shortcut, used for filtered menu (ESC+F4).
First attempt does work - the second and all others doesn't.

Concerning fixed for Maximized window. Partially this focus is done)))
I specifically pointed out to you as an example one utility for editing XML files - because it has an unusual approach to working from the command line: it accepts only one file from the input! If you submit two, only the first of them opens.
But your utility probably still just calls the same editor as many times - as many files with a similar extension have been allocated. And that's why this utility still opens twice on the monitor if two XML files were selected.
BUT! only the first window still opens to the maximum, as I wanted it to. The second editor opens with a standard window size. Is there any way to fix this? So that all the windows of all editors open taking into account the requirement in the size of their windows?

By the way, so what is your strategy for opening multiple files?
One call to one instance of the editor with the parameters passing to it in the command line all the selected files of those extensions that are associated with it in the utility.
Or: calling as many editors - how many files of a suitable extension have been allocated?

Although it has come to me - I can check it myself ... And yes. You call one instance of the editor for each file.
Please don't do that! Call one editor and pass it a list of all selected suitable files in the parameters!
And for special cases - like my XML file editing utility - in the settings, just add a special tick "Call mode: 1 Editor - 1 File". Thus, by default, for most programs that can accept a list of several files in their command line and process them accordingly: we will get simple and correct behavior.
And for any special programs, the option of calling an editor for each file will be available. If they don't understand the list of files in their command line.

BTW, why if you talking about the (pre)release version like: 1.0 \ 1.1 - inside the real FileVersion information resource block you use:
1.1.34.04 or 1.1.35.00 numbers?
1.1.34.04 is yours release 1.0 in fact.
1.1.35.00 is yours release 1.1.
Thus the real diff is on the third subversion digit block: 34 -> 35???
Last edited by AntonyD on 2022-11-06, 15:17 UTC, edited 1 time in total.
#146217 personal license
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *AntonyD »

Concerning
"Language:
The Gui only has a few buttons which are hardly worth translating"
I highly doubt it. IF a user wants to use some very useful utility - the first thing to be searched is the presence of their own interface language!
At least in our country.))))
Does not matter- how many GUI elements are here. So - IF the AHK script in it's essence support internationalization of GUI elements...
Let's do it! Let's translate ALL!

"Meny by Ext:
I don't think I'll do this it would mean more actions to open the desired program because you need to expand the _ext_ menu to get to the editor you want."
But the whole point is precisely in the search for the editor consciously and logically and not by icon and by name.
If I made the opening of CPP files in three different editors, for example, then there is no benefit from that these editors
will simply be listed one by one. More important and useful when choosing is only the moment that FOR the CPP extension
there ARE options for opening with editors X, Y, Z ...
#146217 personal license
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *hi5 »

1. I can open one file after another just fine so it keeps on working as far as I can tell so not sure what is going on. It opens 5, 6 notepads in a row for example so it keeps working.

2. Esc never closed the editors / settings windows (I won't change that, Esc is already a special key and I'm glad I got it to work without interfering with TC)

3. I do run the program each time, this never caused an issue for me (in 10+ years) but there might be programs that don't like it - windows takes care of "program is already running afaik". Do note that there are FOUR methods of opening files - normal is run again as "program.exe 'path to file\myfile.txt', then there is filelist (similar to %L in TC), drag & drop, and cmdline - what works with which program is up to the user to try.
Some programs can't open multiple files at once (or in one program window) but each new file is an instance so to speak - I don't take that into account as I don't use such programs myself and probably would have to resort to program specific settings. In that case I would suggest the editor to be a "script" which in turn would launch the program with some preferred settings (see a discussion earlier in this thread about autocad https://www.ghisler.ch/board/viewtopic.php?p=360448#p360448 where the user opens a launcher)

F4MM waits for the the executable to exist, I can imagine if there is already a version running and a new version is created it won't process the correct window. You can test this by setting it to Minimized, open a file, Maximize the window manually, open second file, it probably Minimizes the Maximized window as that is the first window it sees - I don't think there is a reliable method to detect "wait for new window" so speak (there is a PID command for the run command in AutoHotkey but not all programs return one so that is not a viable option) - Window title is also unreliable as not all programs have a meaning/readable window title to distinguish them.

A helper program (launcher) would work in such cases as you could take into account the specific solution for such a program (be it PID, window title, windowsize or position)

4. version is script (program) version hence 1.1, product version is AutoHotkey version hence 1.1.35
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *AntonyD »

1. I can open one file after another just fine so it keeps on working as far as I can tell so not sure what is going on. It opens 5, 6 notepads in a row for example so it keeps working.
Ok, could we have a special (logged) program, which will write all actions??? So you can compare your variants and my variants of execution the same actions.
2. Esc never closed the editors / settings windows (I won't change that, Esc is already a special key and I'm glad I got it to work without interfering with TC)
Ok, no problems - just IMHO have to be documented well...
3. I do run the program each time, this never caused an issue for me (in 10+ years) but there might be programs that don't like it - windows takes care of "program is already running afaik". Do note that there are FOUR methods of opening files - normal is run again as "program.exe 'path to file\myfile.txt', then there is filelist (similar to %L in TC), drag & drop, and cmdline - what works with which program is up to the user to try.
Well, then I must admit that I don’t understand at all - what and how to choose in the settings of this utility, so that for all programs / editors that I will add to the settings, you can follow the following rule:
for the extension(-s) X (...Y,Z..) you need to call the editor using the main.exe file along the full path: D:\tools\main_editor\. Moreover, call only ONE instance of the editor, passing in its command line all the full paths to the selected files with the appropriate extension.
Like: D:\tools\main_editor\main.exe "d:\docs\file1.txt" "d:\docs\file11.txt" "d:\docs\file23.txt"

It is not clear why the processing with PID does not work. If there is a win32SDK function (in the wrapper of the ahk script) that lists all current processes indicating their PID (because windows itself assigns this parameter to any process in the system when it starts), then you can also make a list of processes by name filter, getting a list of PIDs, then call editors, again get a list of processes by name filter, getting a NEW list of PIDs. But in this case, NEW entries will appear there, which will correspond to the new processes of the newly launched editors. It remains to apply the maximized window property on these new PIDs.
Last edited by AntonyD on 2022-11-06, 17:51 UTC, edited 1 time in total.
#146217 personal license
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: F4MiniMenu (AHK): F4Menu w. Drag&Drop, filelist, cmdline (XYPlorer, Everything, Explorer, Double Commander)

Post by *hi5 »

The https://www.autohotkey.com/docs/commands/Run.htm command has an option to return an OutputVarPID, but the problem is that not all programs that are started this way via "Run" return a PID (the OutputVarPID is empty) so I can't use it, same goes for title.
Keeping a list of PIDs and waiting for new ones, or new "windows" is not something I'm going to do as it won't be needed for 99.999% of the programs out there (I never encountered it for example).

For such cases a launcher (separate program) would have to be used, if this is beyond the users ability then so be it.

Which method to use for which program is up to the user to find out.
Like: D:\tools\main_editor\main.exe "d:\docs\file1.txt" "d:\docs\file11.txt" "d:\docs\file23.txt"
That is want cmdline does - see cmdline support https://github.com/hi5/F4MiniMenu/blob/master/readme.md:
cmdline support

In case you need to pass the selected files to the program on the command line (program.exe file1 file2 etc) you can use the cmdline method.

Examples cmdline usage:

Program: C:\Program Files\Meld\Meld.exe
Method: 4 - cmdline
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Post Reply