See:
This project houses two packages:
windetect Windetect is a Tk library which provides the detection functionality for tracking windows in a GUI with the mouse.
wintrackgui Wintrackgui is an inspection tool for developers of Tk GUI's. While tracking individual windows in a GUI with the mouse pointer, wintrackgui outlines them and displays their pathname in a small widget. Window pathnames reported in this pathname widget may be copied to the clipboard using a keyboard shortcut.