Here is my code to find the name of the active window. I now need to be able to find the location of the program.
import win32gui
window = win32gui.GetForegroundWindow()
active_window_name = win32gui.GetWindowText(window)
print(active_window_name)
How do i find the location of the program and file using either the name or anything else with out manually inputting the name.
win32process.GetWindowThreadProcessId(window)will return the thread and process IDs that own the window. For a console window, the owner is conhost.exe, but the API special cases this to return either the initial process that attached to the console or, if that process has already exited, the current foreground process in the console.