Get last focused window's handle..?

kasdoffe

Regular
Joined
Aug 27, 2003
Messages
57
How can I get the handle of the window that was last focused on before my program got focus? And, how can I get that handle while my program is running too?

For instance, say I have two MS Word applications running, WORD1 and WORD2. If I click on WORD1, then start my program, I want to get the handle of WORD1. Now, while my program is running and I click on WORD2 and click back to my program, I want the handle of WORD2.

Can this be done? I've used the GetForeGroundWindow API in my Main() method of my program to get the last window, but I really need to be able to get it while my program is running too...
 
I've been thinking about this more and workarounds to my problem. Is there any way to send a command or set a variable in another running process? This may work for me..
 
Back
Top