I am writing a program which requires to get path from already open File Explorer / filedialog.
For example, I have opened some folder in File Explorer. It may downloads folder, program files folder or even desktop. Now I want to run a Python file and get the full path to the folder which is being displayed on the screen. For downloads folder, it should return C:\Users\User123\Downloads
or if Program Files folder is open, C:\Program Files
.
I tried reading,
- How to get the current file type at filedialog in tkinter
- Get full path of currently open files
- Python - How to check if a file is used by another application?
I even tried searching online. But none of them work.
I want something like,
import some_library
path = some_library.getPathFromFileDialogOpenedOnScreen()
print(path)
I am using Windows 10 - 64 bit and python 3.10
Can somebody help? Thanks in advance.
(For those who will ask "Why do you want to do this?", I am doing this for my college project!) :)