PDA

View Full Version : Question to Windows developers



baegsi
08-21-2005, 11:09 PM
A totally Windows noob question. I need to retrieve information about the layout and content of any given Windows application. Would it be possible to get

the positions of all buttons
a label or some kind of "name" from each button
the menu entries
from a running application in Windows?

The information has to be somewhere because Windows has to layout the application but how difficult would it be to get it?

Any hints are appreciated.

Thanks :)

wazoo
08-21-2005, 11:16 PM
The answer my friend is blowing in GetWnd()...

baegsi
08-22-2005, 04:27 AM
Thanks for the hint. Would it be a lot work to give me a small snippet on how to retrieve, for example, a list of buttons an application has? Just a few lines to get me started?

I'm planning to integrate a small dll into my Java code. I'm trying to figure out if I can do this by myself or if should hire someone for that.

Speaking of: do you know good places to find Windows developer? I know getacoder etc, but I mean more a developer forum like this one here.

C.S.Brewer
08-22-2005, 07:19 AM
The answer my friend is blowing in GetWnd()...
some sentences are just waiting to be said, :D

Ska Software
08-22-2005, 07:27 AM
The answer my friend is blowing in GetWnd()...

I wanted to start a punk rock programmer band in which one of the gimmicks (among many) would be in counting off as 0 1 2 3! instead of 1 2 3 4! Of course fitting in that extra syllable would be a hassle.

wazoo
08-22-2005, 08:39 AM
I wanted to start a punk rock programmer band in which one of the gimmicks (among many) would be in counting off as 0 1 2 3! instead of 1 2 3 4! Of course fitting in that extra syllable would be a hassle.

That is a toughie...maybe count in hex??

"And an A, B - A, B, C, D!"

Of course the audience would assume that you're just rambling through the alphabet, but YOU know better..;)

Naturally, you'd have to be The Hex Pistols

@baegsi: Seriously, google GetWnd (and maybe "sample" or "tutorial") and
it should lead you to what you need to find. I've used it a lot of times, and it IS an easy call. Every control in Windows is a HWND, so once you find one, you can snag all the child controls off of it..

I think even the MSDN has some sample code in the definition of GetWnd itself...(IIRC)

hth,

ggambett
08-22-2005, 08:45 AM
I wanted to start a punk rock programmer band in which one of the gimmicks (among many) would be in counting off as 0 1 2 3! instead of 1 2 3 4! Of course fitting in that extra syllable would be a hassle.
Or even better : zero-zero zero-one, one-zero and one-one!

mahlzeit
08-22-2005, 09:43 AM
Here is an example (http://www.codeproject.com/cpp/windump.asp) of using GetNextWindow().

wazoo
08-22-2005, 10:50 AM
Or even better : zero-zero zero-one, one-zero and one-one!

Good one though ggambett. That was funny.

AddRef, Release, QueryInterface and IUnknown!

okay okay...This is getting silly.

Colonel: "Quite agree, quite agree...silly, silly, silly. Right! Get on with it!"

James C. Smith
08-22-2005, 08:42 PM
Is this to find the positions of your own buttons in your own window or are you trying to peek into other applications and find their buttons?


Of course this kind of thing will only work if the buttons in the Windows were created with the standard Windows GUI tools (user.dll). Most games roll their own GUI elements. If you try to enumerate all the buttons in any game I ever worked on you will find none of them have any. They all have things that look like buttons, but they are not anything Windows would know anything about.

baegsi
08-22-2005, 11:40 PM
Is this to find the positions of your own buttons in your own window or are you trying to peek into other applications and find their buttons?I'm looking for the gui layout of other applications. But I'm only interested in actual buttons, not simulated ones.

(I have to admit that my project is only slighted related to game development :o , but I decided to post it anyway because here are so many helpful coders. Sorry, I hope that's okay...)

wazoo
08-23-2005, 01:36 AM
hmm..

I think you'll have to sort of hardcode a small hierarchy then to scan through the existing window app to find what you need..

1. Grab the HWND associated with the window text of the application (ie. "Gamespy" or whatever the heck it would be)..look at the EnumWindows method in the MSDN.

2. Within THAT HWND you'd cycle through the other child controls.
Maybe look at EnumChildWindows using the HWND discovered in step 1.

3. GetWindowText MAY not work when working in step 2 to find the button you want...here's what I saw in the MSDN:


To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.


Hth...I've never actually done it, so I hope I'm not misleading you here..this just seems like the most logical approach to me..

hth