Recent

Author Topic: [Closed] How to find active folder path?  (Read 4446 times)

loaded

  • Hero Member
  • *****
  • Posts: 568
[Closed] How to find active folder path?
« on: November 23, 2021, 07:43:05 am »
Hi All,
Given     : I have a situation about saving the image on the Clipboard to the active folder.
Wanted  : Is there a way to get the active folder path in file explorer?
Solution : ?
Any help would be greatly appreciated. Respects.
« Last Edit: November 23, 2021, 01:06:49 pm by loaded »
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1967
  • Former Delphi 1-7, 10.2 user
Re: How to find active folder path?
« Reply #1 on: November 23, 2021, 08:19:05 am »
Define what you mean. by "active folder".
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

loaded

  • Hero Member
  • *****
  • Posts: 568
Re: How to find active folder path?
« Reply #2 on: November 23, 2021, 09:12:12 am »
I meant current file path in Active File Explorer.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

Zvoni

  • Hero Member
  • *****
  • Posts: 1182
Re: How to find active folder path?
« Reply #3 on: November 23, 2021, 09:38:33 am »
How is that supposed to work?
You have File Explorer open, but the moment you click in your Program the File Explorer loses focus
What about if File Exploerer is not open at all?
What about multiple File Explorers open showing different folders?

I'd rather think again about your design
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

loaded

  • Hero Member
  • *****
  • Posts: 568
Re: How to find active folder path?
« Reply #4 on: November 23, 2021, 10:11:27 am »
trev and Zvoni thank you very much for taking the trouble to think about the subject, even for a moment, and responding.
Zvoni, Yes, you're right, I hadn't thought of the focus point.
In this case, I should say:
When I copy the screenshot to the clipboard with the image recorder, I want to save the image file in the last processed folder.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

Zvoni

  • Hero Member
  • *****
  • Posts: 1182
Re: How to find active folder path?
« Reply #5 on: November 23, 2021, 11:22:34 am »
If you've already processed "something" successfully in earlier steps, just save the last path in a variable?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

loaded

  • Hero Member
  • *****
  • Posts: 568
Re: How to find active folder path?
« Reply #6 on: November 23, 2021, 11:53:10 am »
I am currently doing map work and dealing with satellite view and other technical details of each parcel. And all these details are saved in the folder belonging to the parcel. For example, today I had to deal with 136 folders. So there is no fixed file path.
Guys, I'm done for now. He is no longer in a hurry, if there is an improvement, it will be beneficial for the future. For your information. Respects.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

GetMem

  • Hero Member
  • *****
  • Posts: 3741
Re: How to find active folder path?
« Reply #7 on: November 23, 2021, 12:12:20 pm »
@loaded

Try something like this:
Code: Pascal  [Select][+][-]
  1. type
  2.   TfMain = class(TForm)    
  3.     procedure FormCreate(Sender: TObject);
  4.   private
  5.     FScreenShotDir: String;
  6.   public    
  7.   end;      
  8.  
  9. //...
  10.  
  11. procedure TfMain.FormCreate(Sender: TObject);
  12. begin
  13.   FScreenShotDir := GetAppConfigDir(False) + 'ScreenShots\';
  14.   if not DirectoryExists(FScreenShotDir) then
  15.     if not ForceDirectories(FScreenShotDir) then
  16.       FScreenShotDir := GetTempDir(False) + 'ScreenShots\'
  17. end;
  18.  

Now you have a base screenshot directory. The path on windows typically looks like this:  C:\Users\%USERNAME%\AppData\Local\%YOURPROJECTNAME%\ScreenShots\. The method works on other platforms too. When needed, you can create subfolders  for parcels, like this:
Code: Pascal  [Select][+][-]
  1.   SubDir := FScreenShotDir + 'parcel1\';
  2.   if CreateDir(SubDir) then
  3.     SaveScreenhotToFile(SubDir + 'photo.png')
« Last Edit: November 23, 2021, 12:38:22 pm by GetMem »

loaded

  • Hero Member
  • *****
  • Posts: 568
Re: How to find active folder path?
« Reply #8 on: November 23, 2021, 12:56:06 pm »
GetMem, Thank you for the number of characters you wrote.
Most of the time, I work in the form of saving to a certain folder as you describe. Then I distribute it to the relevant folders manually.
But now things started to increase, and this process began to be painful.
I need to solve this problem directly at its source, in the folder it is related to.
In the meantime, something occurred to me;
To add to the menu that comes with the right click in the folder view.
I sailed the sails and diverted the course in this direction. Respects.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

nouzi

  • Sr. Member
  • ****
  • Posts: 251
Re: [Closed] How to find active folder path?
« Reply #9 on: November 23, 2021, 04:30:04 pm »



Code: Pascal  [Select][+][-]
  1.  
  2. caption := '-'
  3.  
  4.  
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

loaded

  • Hero Member
  • *****
  • Posts: 568
Re: [Closed] How to find active folder path?
« Reply #10 on: November 23, 2021, 05:21:24 pm »
nouzi, your answer is very sincere and sincere.
Thank you very much brother.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

 

TinyPortal © 2005-2018