Page 1 of 2

Selected file/folder-path to memory (filemapping)

Posted: 2018-05-22, 05:34 UTC
by dragonetti
Within the windows API you have the commands:
MapViewOfFile
OpenFileMappingW
CreateFileMappingW

If I am not mistaken it writes data into a certain part of the memory.

Could it be made possible to have an option within totalcommander that writes the currently selected file/folder-path to the memory but in a way so that it is stored in reachable way for the user, the above windows api commands are an example of how it could be implemented using thos commands. I am not stating it should be done using that within tcmd, it is just for example purposes.

This might open an easier way for users to execute something based on the selected file/folder under the cursor.

What follows now is not really important but might give you a better idea of what I mean.
Below follows an explanation about the 'filemapping' used in my case/environment. It just gives an example of what I mean.

Regarding the below image 'tcmd_request.jpg':
On the leftside within the black rectangle you see 2 code parts (process A and process B) when the code is executed the code under Process A writes '5' to the memory.

The code under process B reads that memory section and outputs it.
(The 'out' command, outputs.)

On the rightside the content of the 2 functions 'Create' and 'Open' is shown.

Image: https://image.ibb.co/fZUHRT/tcmd_request.jpg

So the idea is to write the selected file/folder to memory and then the user could act upon it using his own scripting environment.

It is not easy for me to explain because I have no C++/C# experience but many environments allow usage of 'memory filemapping' I was hoping it could be implemented within tcmd.

Posted: 2018-05-22, 07:46 UTC
by Horst.Epp
I guess Christian and no other File manager author will do so.
Memory mapped filesd are not necessary at all
to interface your own scripts with TC.
Also for me its totaly unclear why you want to use such environment
if you don't have any C++/C# experience.

Posted: 2018-05-22, 08:13 UTC
by Stefan2
2dragonetti

We can exchange information with TC by utilizing the Clipboard, a temporarily file or SendMessage action.

TC support us by providing parameters for current and target paths and a list with path\names of selected files and folders.

We can use script languages like JavaScript, VBScript, PowerShell or tools like AutoHotkey, AutiIt, PowerPro or NirSofts' nircmd or tools like MVVs' TCFS2.

See http://www.ghisler.ch/wiki/index.php/Scripting_utilities




Plugin-authors have even better possibilities to control TC.
https://www.ghisler.ch/wiki/index.php?title=Plugin
https://www.ghisler.ch/wiki/index.php?title=List_of_64-bit_plugins_and_addons






 

Posted: 2018-05-22, 09:09 UTC
by MVV
TC is not a RAM disk driver to allow keeping files in memory, and mapping API doesn't allow accessing files by another programs in any way, mapping is only used for reading/writing within one process.

Also I can't imagine that accessing files from memory of another process may be easier than reading them from disk...

Posted: 2018-05-22, 12:48 UTC
by Hacker
I guess dragonetti would simply like to use a RAM disk program?

Roman

Posted: 2018-05-22, 15:23 UTC
by dragonetti
I did not request that the contents of a file or folder is placed in the memory. I requested that the selected file/folder path is placed in an accessible part of the memory.

For example, the user selects (left clicks) on the folder: "d:\mp3" in the left pane then the the path (NOT contents) will be written into an accessible part of the memory. Based on that path certain action could be taken.

I stated that I do not have C#/C++ experience BUT I also stated that other environments allow usage of the windows API functions I stated in the beginning of my post. See also image I posted, it gives me the option to use those API functions, but those where just examples.

Again, the idea is:
- User left clicks a path (file/folder) in left or right pane.
- tcmd puts cursor on it
- tcmd writes somewhere in memory the selected file/folder path (NOT contents).
- finally, user could trigger one or more actions based on that path

I know this is a very specific request.

Posted: 2018-05-22, 15:40 UTC
by Dalai
2dragonetti
Since you've been a forum user for many years, I suspect you know about the %L, %WL and similar parameters in the button bar and TC start menu. What I don't understand is how your suggestion is different from those parameters and why you don't want or can't use them. Could you elaborate on this, please?

Regards
Dalai

Posted: 2018-05-22, 15:48 UTC
by dragonetti
@Dalai
The %.. parameters passes arguments to specific scripts/executables/applications...etc when you click on that button on which you assigned those arguments.

But how could I for example, execute an action the moment an .jpg file is left clicked. Or execute an action when a file or folder within "d:\mp3" is left clicked.

For that you need the full path of the current item under the cursor.
(selected file/folder in left or right pane).

Posted: 2018-05-22, 17:29 UTC
by Dalai
dragonetti wrote:The %.. parameters passes arguments to specific scripts/executables/applications...etc when you click on that button on which you assigned those arguments.
Correct.
But how could I for example, execute an action the moment an .jpg file is left clicked. Or execute an action when a file or folder within "d:\mp3" is left clicked.
To save one click? Uh, OK... You're one of the lazy ones like me, eh ;)? Can't imagine a scenario where this would be useful, but I probably lack imagination. So WM_COPYDATA wouldn't be of any use either. Hm.

Regards
Dalai

Posted: 2018-05-22, 19:34 UTC
by Hacker
dragonetti,
Would the clipboard suffice?

Roman

Posted: 2018-05-22, 20:06 UTC
by Stefan2
dragonetti wrote:I did not request that the contents of a file or folder is placed in the memory. I am requested that the selected file/folder path ....
Clear, anyway.


dragonetti wrote:...placed in an accessible part of the memory....
Latest since VistaTM, a user has no access to memory anyway, isn't it?




 

Posted: 2018-05-22, 20:50 UTC
by dragonetti
@hacker, clipboard would not suffice because it needs to happen the moment the user left clicks in left or right pane. The path (not contents) of the selected file/folder would then be written into the memory (certain location) which could be accessible by the user if the path was written using for example the API commands I stated in my first post. (those where just examples). I think using clipboard for this, is not the best approach when compared to filemapping method. I think the filemapping method works faster (not 100% sure).

@Stefan2
You can have access to the memory as long data is written in such a way so that it is meant to be read. That's why I gave the above 3 api commands as an example. If you write the path in that way into the memory and document that the left clicked path is written at "this memory location" then the only thing the user has to do is access that location. With "this memory location" I am referring to the API commands I stated in my opening post.

The reason why I choose those commands because they are windows API commands which can be used in many environments, for example AHK and Autoit can use the windows API. I am not 100% sure of this but I am almost sure of it. If I am not mistaken tcmd is written in Delphi Lazarus and I read that Delphi can use the windows API. But I am not 100% sure of this and even if this is or is not the case, the commands I showed where an example.

It boils down to quickly read the left clicked item (in left or right pane, which could be file or folder). Using a method that is reasonably fast and usable in many environments. And then triggering action(s) on that left clicked path. (left clicked path = the left clicked item in the left or right pane).

Posted: 2018-05-22, 21:41 UTC
by Hacker
dragonetti,
it needs to happen the moment the user left clicks in left or right pane
Seems to work quite acceptably:

Code: Select all

#IfWinActive, ahk_class TTOTAL_CMD
LButton::
	Click
	PostMessage, 1075, 2018
Return
Roman

Posted: 2018-05-22, 22:34 UTC
by dragonetti
@hacker
Thank you for the example but the action needs to be based on the full path of the file/folder clicked upon not just the the left click itself. (I also do not use AHK, but I mentioned it as an example).

So for example, user left clicks on "test.mp3" in the left pane which is in "d:\mp3" then the full path get's written into the memory "d:\mp3\test.mp3" now that I have the full path on which is left-clicked then I can decide what action I want to perform based on that path (d:\mp3\test.mp3) which I grabbed from the memory.

Posted: 2018-05-22, 23:30 UTC
by Hacker
dragonetti,
Well, using the example script above, upon clicking on some file in TC its full path gets loaded into the clipboard and then you can decide what action you want based on that path. Just grab it from the clipboard.

Roman