Detect message box of another application.

Hi,

I want my program to be able to detect when there is a message box showing in a game.
The message box that appears stops you from clicking anything in the game until you click ok.
But it's doesn't look like the normal box you would get with MsgBox("").
It has a skin...
Theres a picture of the msgbox here: http://diablo2trading.addyour.net/temp/D2%20MsgBox.JPG

Can anyone help please?
Thanks In Advance
mms_master
LVL 5
mms_masterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ramesh SrinivasTechnical ConsultantCommented:
So it is not really a msgbox object?

I assume that it is a normal windows form set to accept an OK command.

What is the purpose of detecting the msgbox?

If it is a windows form then you can add code to it's load event.

regards,

KS
0
Bob LearnedCommented:
Do you know what the window class is for that dialog?  Use Spy++ to find out, if you don't know.

Bob
0
mms_masterAuthor Commented:
I don't think its a msgbox object because of the skin...
I can't add code to it's load event because it's not my program...

I know the class of the actual game window. But I don't know the class for the messagebox itself. (thats if it is defferent to that of the actual game window)

I will have a look to see if it has its own class. And I'm guessing that if it has its own class I can just use FindWindow to see if its there... The only problem with checking if it has a class is I have to wait for the message to appear and it may take a while. Ill let you know if it has one once its appeared.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Mike TomlinsonMiddle School Assistant TeacherCommented:
"The only problem with checking if it has a class is I have to wait for the message to appear and it may take a while."

Connect to your game as usual and then pull your Network cable out of the back of your computer...  ;)
0
Bob LearnedCommented:
I wanna be like Mike ;)

Bob
0
mms_masterAuthor Commented:
hmm, nice idea :D
why didn't i think of that :$ lol
I'll give it a go now.
0
mms_masterAuthor Commented:
I use WinSpector because VB.NET 2005 Express Edition doesn't come with Spy++
I unplugged my network connection and the message appeared.
BUT it didn't appear as another window on WinSpector.
0
Bob LearnedCommented:
Did it appear as a child window of the main window?

Bob
0
mms_masterAuthor Commented:
Sorry i'm new to WinSpector, ive never used nothing like it before.
Im assuming that the child window would make a + next to the main window and then be listed underneath the main window when u expand the tree?

If thats correct then no it didn't come up as a child window.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
It's probably being drawn directly to the screen using DirectX or OpenGL surfaces.

IMHO, you're SOL...   =(
0
mms_masterAuthor Commented:
IMHO?? SOL?? what?? lol
0
Bob LearnedCommented:
Out of luck

Bob
0
Bob LearnedCommented:
(I)n (M)y (H)umble (O)pinion

Bob
0
mms_masterAuthor Commented:
hmm, Anyone got any other ideas?

The only other thing I can think of is reading pixels.
I've actualy got a question open about reading pixels. It come down to looking for the message box and I haven't had a reply since :(
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
SOL  --> {Insert Expletive} Outa Luck
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
If the "msgbox" appears in the same position everytime I suppose you could try screen scraping.

Though this approach would most likely be problematic and probably be a CPU hog iterating thru pixels to look for a match.

Also, depending on how the game draws itself, a screen capture may not even be possible.
0
mms_masterAuthor Commented:
Just an idea.
I once saw VB6 source code that could enable and disable controls of any windows forms.
It used api to find the name or handle of the control or something and then more api to enable or disable it (not sure how).

Is there any way to check if the ok button on the "msgbox" is there?
Don't know if it will work because as Idle_Mind said, it looks like it's been drawn directly to the screen using OpenGL or Direct3D. But surely it must have some sort of handle for it to be clickable.

The way the program I saw before required the user to drag an icon over the required control. it would then get the handle or something for the control and allow u to enable/disable it.

If i told you that the message box always appears in the center of the game window (so i can get co-ordinates of the button) do you think this method would work?
If so can you tell me how to do it?

NOTE: I don't want to disable/enable the button like in the example, I just want to find if the button is there or not. (if the button isn't there when checked then obviously the "msgbox" hasn't popped up...)
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
If WinSpector didn't show the dialog as a seperate window then the API approach you describe will not work.

    "surely it must have some sort of handle for it to be clickable."

Just because something is clickable doesn't mean it has its own window with a handle.  You can write graphical interfaces that take action and give feedback based solely on the location of the cursor as it is moved and when it is clicked...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mms_masterAuthor Commented:
Looks like my program will just have to keep sending keys to nothing if the game disconnects :(

Could someone tell me how to use My.Settings to store an array instead then plz :)
I go to the program properties and click the settings tab.
Then I type in the name for the new setting and set the scope to 'user'
But I press browse on the type dropdown box because Array isn't allready there.
Then it gives me a huge list to look through and I can't find array anywhere.
0
mms_masterAuthor Commented:
Ah, seconds after posting this I found system.collection
Didn't see it first time coz I was looking for the word array...
nevermind then.

I'll split the points between Idle_Mind and TheLearnedOne for all the help :)

Thanks
mms_master
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.