News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Detect a MessageBox?

Started by Trope, March 05, 2005, 09:16:19 PM

Previous topic - Next topic

Trope

I am new to MASM and this is my first post in this great forum.

I was wondering, if I knew the Title of a MessageBox that program One is (may) display, is it possible for program TWO to somehow detect that that particular MessageBox is being displayed and if so, to close it?

Thanks! Again, kick ass forum!


Grincheux

A MessageBox is a window.
Using FindWindow, supplying the MessageBox title can help you to get the window handle.
With this handle you can do anything for this window.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Trope

Finding the window (MessageBox) should be a breeze then. But closing it would be a different story it appears.

I have a feeling I am going to need to Hook the API, and write my own function. So far anyways, I can't find any examples of how to close a MessageBox programatically.

Petroizki

Just send WM_CLOSE to the window.

invoke FindWindow, NULL, ADDR szWindowName
invoke SendMessage, eax, WM_CLOSE, 0, 0

hutch--

It souds like if you can get the handle for the MessageBox dialog, you then enumerate child windows and find the window hadle for the button you need to push.

You could also try sending a WM_SYSCOMMAND to the window with the SC_CLOSE flag in the word parameter but I don't know if it will work as they two processes are in different memory spaces.


  invoke SendMessage,hMsgBox,WM_SYSCOMMAND,SC_CLOSE,0
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Trope

 :clap:   

Sending a WM_CLOSE worked like a charm!

Why did I think this would be so difficult???????????

Thanks guys for your help.

Trope