I want to write a process that knows all the time what is the current foreground window.
I know i can use GetForegroundWindow in a loop but i believe it will be better not to check GetForegroundWindow all the time.
so what i'm looking for is something like an event OnForegroundWindowChanged or another method to do so.
I know i can writing an hook in C++ to every process and send the event from there but i prefer doing it all in c# and not to inject a dll to all running process (it don't sounds so stable :)
Thanks,
Omri
I think that what you want is handling of UIAutomationEvents?
Admittedly this is part of windows accessibility functionality and I'm not sure if its always on or requires enabling, but Try here for pointers.