Question setforgroundwindow

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
i have a program that interact with another window. lets say window 1 is the window i am trying to interact with... window 2 is different window that is current in the foreground. so i did a getforegroundwindow to get window2, getprocessbyname for window1. bring window1 to the foreground with setforegroundwindow, do the click and send key to window1 then setforegroundwindow to window2 to bring it all back to the way it was...

but what if there is a window3 that is in front of window1 but not the foreground window. after the process, window3 would be behind window1. how do i keep the same order after the process with window3's introduction? and window1 is the only one i know by name
 
I believe that EnumWindows will give you all the top-level windows in z-order. You can then determine the window that your target is after in the z-order. Once you're done, I believe that SetWindowPos will allow you to specify that the target should be inserted behind that same window in the z-order. I haven't tested any of this but I'm pretty sure it will do the job.
 

Latest posts

Back
Top