views:

163

answers:

2

We have a third party Windows application that we feel is too complex for our users to use efficiently. The application manages a scanner that we're using to scan 3000 documents per day.

The scanner application can be completely piloted using the keyboard.

We are therefore in the process of writing a simple WinForms application that has a small number of large buttons on it that uses SendKeys and some Win32 API calls to send keystrokes to the scanner application. We plan to make this WinForms application full screen and set to the top of the Z-Order.

However, the scanner application sometimes displays error messages in modal dialogs (e.g. scanner paper jam etc). We need to show these error messages in our WinForms application.

Can anyone suggest a technique that will allow us to capture these error messages and show them to our users?

+1  A: 

Not sure if this is the most efficient way, but assuming you have a way to identify those error messages, you can have a loop that will go over all open windows every once in a while, and look for one of those error windows.

Another possible direction to explore is to inject a dll of yours into the other app, and watch the messages passed. I can't say for sure you'll be able to identify those messages and I can't do further research at the moment, but I believe it should be possible. Just Spy++ the other app when such message is popped, and identify the relevant messages.

eran
I'm part way there - since the modal window always has the same title I can use FindWindow from a timer to get it. Now I need to set it modal with respect to my WinForms application window...any thoughts as to how??
Richard Ev
I doubt this is possible... but since you're already showing their GUI in yours, why not read the content of the messages in show it in your own modal window? They probably use the same window and the same text field to present the errors. You just need to identify the error message field, grab the text and present in your own window.
eran
I am pretty sure it should be possible to reparent the modal window using some combination of SetParent and/or SetWindowLong...
Richard Ev
+1  A: 

You might find this Automating applications helpful - it contains info about finding dilogs and dealing with modal dialogs

mikej