?
Solved

Detect message box of another application.

Posted on 2006-04-05
20
Medium Priority
?
465 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:mms_master
  • 9
  • 5
  • 5
  • +1
20 Comments
 
LVL 11

Expert Comment

by:Ramesh Srinivas
ID: 16379137
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16379898
Do you know what the window class is for that dialog?  Use Spy++ to find out, if you don't know.

Bob
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382047
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16382143
"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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16382152
I wanna be like Mike ;)

Bob
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382178
hmm, nice idea :D
why didn't i think of that :$ lol
I'll give it a go now.
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382317
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16382334
Did it appear as a child window of the main window?

Bob
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382374
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16382407
It's probably being drawn directly to the screen using DirectX or OpenGL surfaces.

IMHO, you're SOL...   =(
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382438
IMHO?? SOL?? what?? lol
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 248 total points
ID: 16382454
Out of luck

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16382467
(I)n (M)y (H)umble (O)pinion

Bob
0
 
LVL 5

Author Comment

by:mms_master
ID: 16382508
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16382511
SOL  --> {Insert Expletive} Outa Luck
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16382593
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
 
LVL 5

Author Comment

by:mms_master
ID: 16382746
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
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 252 total points
ID: 16382821
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
 
LVL 5

Author Comment

by:mms_master
ID: 16382956
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
 
LVL 5

Author Comment

by:mms_master
ID: 16382993
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question