2

Here is what I want to do:

1)Open an application with username
2)Give some inputs
3)Open 2nd window for the application with different username
4)Give some inputs again
5)Switch to first application window, do somethg
6)Switch to second application

I am programming in python using the win32gui library. I have tried using the ShowWindow and SetForegroundWindow , but it doesnt work correctly, can someone please explain me what would be the way to do it in a very simple way?

NorthCat
  • 8,315
  • 16
  • 40
  • 45
user3325210
  • 133
  • 1
  • 11
  • You need the window Handler to do that. Since you want to set other application's window to foreground, you might have trouble to find this Handler. Try to acquire it with `FindWindow`, that allows you to obtain a window Handle by it's title. – Havenard Aug 27 '14 at 19:58
  • I have the handle for both the windows, but when I do ShowWindows(h1,3) then ShowWindow(h2,3) then again ShowWIndow(h1,3) it doesnt always work properly – user3325210 Aug 27 '14 at 20:08
  • Ok, when exactly are you using `SetForegroundWindow`? Because `ShowWindow(handle, 3)` only set a window to maximized state, it isn't implicit anywhere it will bring it to foreground. – Havenard Aug 27 '14 at 20:35
  • Thanks for that heads up!!! I am either using SetForegroundWindow all the times or ShowWindow all the times, but its not working correctly in both cases. So just wanted to understand when to use which ? – user3325210 Aug 28 '14 at 13:13
  • You use `ShowWindow` to set its state after you create it or in case you want to hide/minimize/maximize it, and `SetForegroundWindow` when you want to bring it to front. – Havenard Aug 28 '14 at 15:19

1 Answers1

0

Call BringWindowToTop and SetActiveWindow functions.

i486
  • 6,083
  • 3
  • 21
  • 37