开发者

Detecting button enable in another application

I have an application that I would like to write an automated test for. The automated test will mimic an Operator's usage of the application. I cannot change the source code of the application as it is "frozen" for review.

The application will display a pop-up (message) window informing the operator to click on a button after measurements are finished. The button is enabled some time after the message window is closed.

I need to know how to detect when the application ena开发者_JS百科bles this button. My research so far indicates that the application should broadcast a custom message to help the automated testing; but I cannot modify the source code.

Also, the application will enable radio buttons after the "Measurements Finished" button has been clicked, asking if the measurements were valid. I need to detect this also.

Summary:

  1. How do I detect when a button (control) is enabled in another application?
  2. How do I get the handle of the other application?

I am using C# with MS Visual Express 2010 on Windows NT, Vista & 7. If you suggest tools, I need them to be free as the company has a very tight budget.


I think you could do the job using FindWindow API, passing title and receiving the handle.
Then, enumerating children components, you could find the button (if you catch its name, next time you can use it to be quicker) and get the enabled state.
I think you could use AutoIT software (script) or its logic.

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, int nptWindowName);

EDITED:
Check this link to find a simple way to do what you need.
I hope this helps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜