Can I ask why you want to do this? Historically, this behavior had two purposes:
1. Locking access after a certain time period.
2. Preventing screen burn-in.
Currently, both of these things can be done directly from System Preferences. In fact, #2 now tends to be done by putting the display to sleep, rather than using a screen saver, for energy efficiency reasons.
Given that users can configure these exactly how they wish, without your app, what purpose does your app serve? Why does your app need to lock the user out of other apps? If your app is providing security, how you know it's actually more secure than what users can already do with built-in functionality? (If not, why should they use your app?)
Maybe you have really good reasons for doing this. If so, telling us more about your reasons may help us suggest a more acceptable solution.