You're trying to type something into a box, the Start Menu, use your quick launch, rename a file, write an email and all of a sudden another window brings itself to the front or becomes active "stealing focus". This happened to me in Vista, it might happen in XP. You might also notice some Windows flash, becoming active then inactive and so on.
I thought I'd share the solution that I found.
In my case it was a problem with Autoplay. I turned off Autoplay on all drives (told each one to do nothing if a disc was inserted). That solved it.
It seems Vista kept thinking something was in a drive when it wasn't. This could be a floppy drive a real CD or DVD drive or a virtual CD or DVD drive
If turning off autoplay doesn't work, then do a search for ForegroundLockTimeout which is a registry setting.
How to turn off Autoplay in Vista (in XP right click on each drive in My Computer)

Untick the box next to Use AutoPlay for all media and devices