Greetings all,
I have recently begun working in .NET (after many years of the Visual Studio 6.0 languages) for the purpose of automating some test processes at work. While many of the tasks involved have turned out to be much simpler in managed code (I am using VB.NET) I have encountered some difficulties. Specificially, I would like to be able to find out what window currently has input focus (and be able to find what process it is attached to). Some other tasks which are also being troublesome in .NET are:
Getting information about a window, such as its title, position, size etc...
Getting information from a control on a window, such as text out of a text box or the state of a checkbox.
Giving a window input focus.
Note that all these tasks are for a window running in another process. EG: I use the process class to run another program and I need to manipulate and monitor that program.
I know how to do all of these things with the WinAPI in non-managed code. However, if these things can be done with the .NET libraries I would prefer to do so.
By the way: I have noticed something very odd about the Process.WaitForExit and Process.WaitForInputIdle methods. The problem with WaitForInputIdle being that it does not seem to do anything at all (it never seems to "wait" when I use it). With WaitForExit I have been getting some very odd behavior indeed. Take the following for example:
Assume that myProcess is set to open an instance of Notepad.
Now it seems to mee that this should open Notepad, then print "Weeee" into it, then close notepad (waiting up to 10 seconds before proceeding for notepad to close). What is happening for me is that notepad opens, then immediately waits 10 seconds, then when the 10 seconds are up types in "Weee" and closes. EG: The WaitForExit is happening BEFORE the SendKeys and myProcess.CloseMainWindow commands. Very strange.
I have recently begun working in .NET (after many years of the Visual Studio 6.0 languages) for the purpose of automating some test processes at work. While many of the tasks involved have turned out to be much simpler in managed code (I am using VB.NET) I have encountered some difficulties. Specificially, I would like to be able to find out what window currently has input focus (and be able to find what process it is attached to). Some other tasks which are also being troublesome in .NET are:
Getting information about a window, such as its title, position, size etc...
Getting information from a control on a window, such as text out of a text box or the state of a checkbox.
Giving a window input focus.
Note that all these tasks are for a window running in another process. EG: I use the process class to run another program and I need to manipulate and monitor that program.
I know how to do all of these things with the WinAPI in non-managed code. However, if these things can be done with the .NET libraries I would prefer to do so.
By the way: I have noticed something very odd about the Process.WaitForExit and Process.WaitForInputIdle methods. The problem with WaitForInputIdle being that it does not seem to do anything at all (it never seems to "wait" when I use it). With WaitForExit I have been getting some very odd behavior indeed. Take the following for example:
Code:
myProcess.Start()
Sendkeys("Weeee")
myProcess.CloseMainWindow()
myProcess.WaitForExit(10000)
myProcess.Close()
Assume that myProcess is set to open an instance of Notepad.
Now it seems to mee that this should open Notepad, then print "Weeee" into it, then close notepad (waiting up to 10 seconds before proceeding for notepad to close). What is happening for me is that notepad opens, then immediately waits 10 seconds, then when the 10 seconds are up types in "Weee" and closes. EG: The WaitForExit is happening BEFORE the SendKeys and myProcess.CloseMainWindow commands. Very strange.