I think it would be a useful feature to log the full path of a file that a window has open. This would be platform dependent. E.g., On MacOS I can see when I find Skim.app has pid 4031 that it has a number of files open,
> lsof -p 4031 | grep pdf
Skim 4031 alexc txt REG 1,4 2269846 8627682846 /Users/alexc/Downloads/Andrew W. Appel - Modern Compiler Implementation in Java, 2Ed (2002).pdf
Skim 4031 alexc txt REG 1,4 15571908 8594585922 /Users/alexc/Documents/Computer Science/AI/Artificial-Intelligence-A-Modern-Approach.pdf
It might be a bit hard to match which file is open in which window, but at least with Skim the window title contains the file name (without path), so that would be relatively simple to match.
I expect this would be a complicated task, but very useful so you can have a category rule like “PATH /Users/alexc/Documents/Computer Science/” so any window working on a file with that path prefix would be categorized as e.g. “computer science”.