with open(log_file, "a") as f: f.write(f"timestamp - active_window\n")

When choosing a logger, look for these specific capabilities:

A (also known as computer activity tracking software, time tracking application, or usage monitor) is a software tool designed to automatically record how a user interacts with a personal computer over a given period. Its primary function is to capture which applications, documents, websites, or system processes are active and for how long, providing an objective, data-driven breakdown of computer usage.

If you decide to deploy a PC time logger (for yourself or a team):

pc time logger