Your code is correct but it only monitor current opened files only not History of you files and to monitor this you have to run this script continuously (depends on your need)
If you want history also of your executable files(.exe) then window stores that data in registry so track down that to extract all data of your desired exe files
And for PDFs and FileExplorer files you have Recent files option so track that all
And extract all metadata of those files to get history of your FILES as well with .exe files