Home All Groups Group Topic Archive Search About

Detecting Dialogs from other application

Author
26 Nov 2004 1:23 AM
Randall Campbell
I have some C# code that runs via the VSAEngine under a host program. There
is a situation where the host program will display a dialog that will stop
execution of my code. There is no API available to me to prevent this.

Is there a way by either looking at windows messages or a hook, that I could
detect when this dialog is displayed? Once I detect it, I know how to send it
keystrokes so that it will dismiss.

I haven't done any C/C++ windows programming, so if there is a way, I would
appreciate some pointers.

Author
26 Nov 2004 6:35 AM
Ajay Kalra
You should be able to  use SetWindowsHookEx to do this. You could see if you
can catch window creation message in the same process and check if its the
same dialog as you expect by enumerating its childer, or looking at its
caption etc.

Using a hook in .Net is shown here:

http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/default.aspx

-----------
Ajay Kalra
ajayka***@yahoo.com


Show quote
"Randall Campbell" <RandallCampb***@discussions.microsoft.com> wrote in
message news:49FDC624-A9B2-4A44-9732-2776E28CF261@microsoft.com...
> I have some C# code that runs via the VSAEngine under a host program.
There
> is a situation where the host program will display a dialog that will stop
> execution of my code. There is no API available to me to prevent this.
>
> Is there a way by either looking at windows messages or a hook, that I
could
> detect when this dialog is displayed? Once I detect it, I know how to send
it
> keystrokes so that it will dismiss.
>
> I haven't done any C/C++ windows programming, so if there is a way, I
would
> appreciate some pointers.
>
>
Author
28 Nov 2004 7:03 AM
Randall Campbell
Thanks very much Ajay! That did the trick!

Show quote
"Ajay Kalra" wrote:

> You should be able to  use SetWindowsHookEx to do this. You could see if you
> can catch window creation message in the same process and check if its the
> same dialog as you expect by enumerating its childer, or looking at its
> caption etc.
>
> Using a hook in .Net is shown here:
>
> http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/default.aspx
>
> -----------
> Ajay Kalra
> ajayka***@yahoo.com
>
>
> "Randall Campbell" <RandallCampb***@discussions.microsoft.com> wrote in
> message news:49FDC624-A9B2-4A44-9732-2776E28CF261@microsoft.com...
> > I have some C# code that runs via the VSAEngine under a host program.
> There
> > is a situation where the host program will display a dialog that will stop
> > execution of my code. There is no API available to me to prevent this.
> >
> > Is there a way by either looking at windows messages or a hook, that I
> could
> > detect when this dialog is displayed? Once I detect it, I know how to send
> it
> > keystrokes so that it will dismiss.
> >
> > I haven't done any C/C++ windows programming, so if there is a way, I
> would
> > appreciate some pointers.
> >
> >
>
>
>

AddThis Social Bookmark Button