I would like to know how to get the path of the current window which is in focus.
I am writing a script which is waiting for a specific key-combination and when that combination is pressed, I would like the script to get the path of the window in focus.
This is what I have for now.
To get the name of the window in focus:
from win32gui import GetForegroundWindow, GetWindowText
print(GetWindowText(GetForegroundWindow()))
This returns the name of the folder that is open: TestFolder
But how do I get the path of that folder? For instance, that folder in question is on my desktop.
TestFolder -- D:\GM\System Folders\Desktop\TestFolder
How do I get that location through code in Python?