I have used Rayflectar's Project Timers for many years in order to automatically track the time I spend for certain projects, and it has been working incredibly well.
Project Timers simply monitors all current windows titles. If the title of an active window matches a custom substring AND if there is activity in that window, the respective time will be added to the project associated with that substring:
There is only one problem for me that leads to inaccuracies: for example, if I am working in a Microsoft Word document where the title contains "project abc", Project Timers will monitor the time spent in that window and add it to Project abc's time sheet - so far so good.
If however I open any dialog in Word (for example a Format, Insert or Find dialog), Project Timers will think that I am no longer working on "project abc" (because these dialogs will not have "project abc" in their window title), and it will stop the clock of that project, where actually I am still working in that project:
Same goes for quick web searches or the like, where you return to your project window (having the tile "project abc") after a few minutes. Project Timers also in this case will stop as soon as you leave your main work window, and you loose the time spent for that quick web search related to your project.
One possibility to work around this and get somewhat better accuracy of the time measurements would be to introduce a "grace period" where the current projects time keeps running for a custom period of time even after you have left one of the projects windows (for example by opening a program dialog, or doing a web search). As soon as the project window is re-entered, the respective project's time should of course start running again, even if the grace period had expired in the meantime.
Possibly, the grace period time should only be added to the respective project's time sheet if you actually return to one of the project's own windows (having the projects substring in its titlebar) during the grace period. This would prevent that a grace period's worth of time would be added to your project every time when you were actually switching to another project (or leaving your computer altogether).
Unfortunately, Project Timers doesn't have a setting for such a custom grace period. What's more, I have tried to contact the creator of Project Timers, Thomas Anagnostou, but with no success (all his mail addresses I could find are disfunctional).
Thus I think that I am prepared to donate if somebody could re-create a tool that works like Project Timers, but additionally has that adjustable "grace period" when a project window is left.