Hey karpar,
Any third party software conflicting with Windows components can result to this behavior. Hence, putting your system in clean boot state can help in determining the culprit application or program. A clean boot loads only those files and programs that are absolutely required by the Operating System. Upon determining the background application causing the issue, you may contact the vendor for assistance.
Steps to perform clean boot:
1) Click Start, type msconfig in the Start Search box, and then press ENTER.
2) If you are prompted for an administrator password or for a confirmation, type the password, or click Continue.
3) On the General tab, click Selective Startup.
4) Under Selective Startup, click to clear the Load Startup Items check box.
5) Click the Services tab, click to select the Hide All Microsoft Services check box, and then click Disable All.
6) Click OK.
7) When you are prompted, click Restart.
After the computer starts, test and see whether the sporadic behavior of Windows loosing focus continues.
If not, we definitely know for sure that the behavior is contributed by third party software conflicts.
To determine which application, follow the steps mentioned in the article below.
How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
http://support.microsoft.com/kb/929135
After you determine the startup item or the service that causes the problem, contact the program manufacturer to determine whether the problem can be resolved
Having done so, don’t forget to return your computer to start normally.
Reset the computer to start as usual
1) Click Start, type msconfig.exe in the Start Search box, and then press ENTER.
2) If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
3) On the General tab, click the Normal Startup option, and then click OK.
4) When you are prompted to restart the computer, click Restart.
Hope this resolves the issue.
Regards,
Shinmila H - Microsoft Support
Visit our Microsoft Answers Feedback Forumand let us know what you think