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...
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...