Ok, after HOURS - I'm not going to tell you how many - of trying, I'm looking for help!!
I'm trying to write code to snoop at data in textboxes of an accounting application window for my application to automate some other processes.
From the master application window, I EnumChildWindows with my callback function and find the Dialog Window which contains the controls for the data I want. There are NO other child windows.
I can successfully talk to this window with WM_GetText and WM_GetTextLength and verify the window name.
Next I try to GetNextDlgTabItem ( found_window_handle, 0, 0) and it returns the same window handle I passed to it. If I attempt GetNextDlgTabItem ( found_window_handle, 0, 1) it always returns 0. (just changing previous / next)
I then tried to CHEAT and setup a procedure to use GetDlgItem ( found_window_handle, control_id ) - my cheat is to loop for every number between 0 and 99999999 for the control_id. Surprisingly every attempt returns ZERO.
I was reading about Windows Hooks and it stated sometimes messages can be missed because Windows passes them directly to the control rather than the parent dialog window.
If this is the case, Windows must have a table of controls! How do I access this table?!
IF I had not seen this done, I might have given up, but SnagIT -> Object -> Text capture can not only grab the present value of a dialog text object, but it also returns the programmers name for the object. I've also played with password discovery tools that reviel the value hidden behind a password character "*".
I think the solution is hidden somewhere in messaging the parent dialog window, or in discovering the control table or DLGTEMPLATE at runtime. But, the only starting point I have is the Handle of the Dialog Window itself.
Any suggestions, or better, anyone actually done this?!
filthy_mcnasty
March 29th, 2004, 11:37 AM
to be honest i'm having a hard time picking out exactly what you're trying to do. you want to subclass a child window in another process? or just read text from it?
getting the text behind **** in a password field is as simple as a WM_GETTEXT message, it's just a special control that doesn't display anything but the * character but the text is still the pw.
is a program i wrote to take the thinking out of finding a child window and it will generate some code for you because i THINK this is what you're ultimately asking how to do. post back with more info so we can better help you.
kirants
March 29th, 2004, 06:02 PM
Did you try using a tool like Spy++ and see what windows are there and how they are related ? ( parent - child ) . It could happen that the controls u r trying to spy on may not be child of the dialog handle that u have.
Jim Frankland
March 29th, 2004, 06:47 PM
Hi filthy_mcnasty, & Kirants;
VERY GOOD POINT Kirants!
Spy++ does not see these control objects as I use Window Search and move the Finder Tool over the window. Spy ONLY highlights the whole window.
I just tried the Windows address book and those dialog controls ARE discovered by Spy++.
Now I'm confused; there might be a LAYERED INVISIBLE window over these dialogs, I suppose.
The HANDLE of the WINDOW I have seems correct because I can HIDE it, MOVE it, RESIZE it, and it effects this dialog and the contained controls. If I CLOSE it, the controls also close.
So if the window I have is wrong, A. How do you find it, and B. How come this 'not the Parent' effects the controls? (If I size it smaller, the dialogs are cut off.
The Window I have, reports having NO CHILDs.
Also, How is SnagIt finding these dialog controls as I use their Finder Tool and move the cursor over these controls?
kirants
March 29th, 2004, 06:52 PM
It can get little tricky at times. What you could try is to
a. invoke the window that has these controls.
b. Invoke Spy++
Spy should give u a snapshot of all windows in the system. Here you can try to locate the controls and see how the tree heirarchy is.
Jim Frankland
March 29th, 2004, 07:57 PM
What if the controls don't show up in Spy++?
kirants
March 29th, 2004, 08:00 PM
Hm.. could be possibly be windowless controls. I think the browser ( IE kinda ) have these. If you have a form on the browser and have edit boxes, combos etc, you won't see them as individual controls. Just one window handles all the operations on these so called windowless controls.
It could possibly be something similar , in that case. Can't think of anything else.
Sam Hobbs
March 29th, 2004, 08:55 PM
Originally posted by Jim Frankland
What if the controls don't show up in Spy++? Then that is a problem! The controls are probably not controls provided by Windows (the Platform SDK). They are not controls at all if Spy++ does not show any child windows under the main window.
Jim Frankland
April 1st, 2004, 12:54 AM
Ok, I'm stoked!!
I've been banging my head against the wall for two weeks now! :confused:
Some - or Many - depending on your viewpoint - programs no longer use the predefined windows controls which ARE WINDOWS and DO HAVE HANDLES! Many VB programs, Many Active-X controls, All VFP applications, Games, etc, etc, etc... now use BitMap objects with triggers and code which emulate buttons, textboxes, etc. These types of controls are run by the dialog window and are ALMOST hidden to anyone else.
That is why they don't show up in Spy++ and ARE a PROBLEM!
So what is the answer?
iAccessibility Toolkit SDK!! Accessibility is built into 98, ME, XP, 2000, 2003. Addons for 95, and NT are available.
A sample application / Tool (like Spy++) is the AccExplorer. Anyone who hasn't played with this and who thought Spy was cool -- This will BLOW YOUR DOORS OFF!! :eek:
It asks you which program you wish to setup a client - server relationship for Accessibility. THEN the application (server) SPILLS IT'S GUTS! Every sub-window, every menu, every object, EVERYTHING is listed. Coordinates on window, Name, Value, Keyboard Shortcuts assigned, Default Actions (like button clicks) - which can be remotely executed by messaging, ECT...
Now I'm off to read the 230 page manual and learn how to write the code!! WAY COOL! :cool:
Jim τΏτ
RussG1
April 1st, 2004, 04:42 AM
My guess would be that the dialog you are referring to, is a CDHtmlDialog (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vcrefCDHtmlDialog.asp) (or something similair, does Spy++ show the window as "Internet_Explorer_Server"?) and the textboxes are not Edit Controls but rather HTML input elements. I have not really used these types of dialogs, but I think you should be able to access the controls through the DHTML Object Model, using the IHTMLDocument2 interface, etc.
You may want to take a look at Programming and Reusing the Browser (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/prog_browser_node_entry.asp) and MSHTML Reference (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp) on the MSDN web site for more information.
Shino
April 8th, 2004, 01:02 PM
Is it possible to list all controls of a window? Like listing every available listbox, editbox, menu's, etc.. ?
I understand the EnumChildWindows function already but it does not do it in certain cases. If someone is willing to try it just to see what I mean, if you use it correctly you should get a list of what Child Windows are running on the desktop.
I use H = GetDesktopWindow() for the main handle
and then use EnumChildWindows H, AddressOf EnumChildProc, 0.
If I double click in one of the window's titles in the list I have it will do EnumChildWindow for that window selected.
It works correctly if I double click on mIRC for example and list's all windows in it and the editboxes so I can sendmessage to it.
But for MSN Chat Windows all it gives me is a handle called DirectUIHWND.
I want to know if there is a way to list all objects (textboxes, listboxes..). Or I wanna know if anyone can clarify me why this isn't working for all applications?
And where can I find ACC Explorer?
Thanks :)
Sam Hobbs
April 8th, 2004, 01:28 PM
You are asking many questions yet none of them are entirely clear. You ask about how to enumerate controls and you ask why you are not getting windows that are children of the desktop, so it is not clear what you are asking. Many of us prefer not to answer questions such as this because we have to guess at what is being asked and many times the person that is not clear says that our guesses are wrong.
I notice that this is your first post. You should create a new thread instead of responding to an existing thread. Your questions are different from the question asked in this thread originally.
I think that windows on the desktop are not child windows by default, so that is probably part of the reason that you are not getting the results you expect.
So create a new thread and try to be more clear about what you are asking. I think that if you look closer at the documentation, you will discover that there are reasons for everything you are confused about. So instead of telling us to try it, you are more likely to get answers if you can provide a specific example.
I don't know what mIRC, DirectUIHWND, and ACC Explorer are. Other people might and they might be able to help but others such as I don't know what they are and therefore samples such as those don't help me help.
Shino
April 8th, 2004, 02:12 PM
ACC Explorer is mentionned in the 2nd post above mine, so I was asking about that.
And DirectUIHWND is the Window Class that I get when trying to Enumerate the child windows of an MSN Chat window.
For example, I double click on a nickname in the list and it pops up a Chat window. I then do my EnumChildWindows on it and all I see is that.
So thats why I was asking if there was any other ways to Enumerate objects from a window instead of using EnumChildWindows.
Some function to list objects such as (listbox, editbox, buttons, etc..) so I can refer to them or interact with them directly.
Sorry if I was unclear, as I read the rules, it says not to make a new post if a post similar was already posted. And the post does make reference to the same thing im trying to do, its just the member is doing it on another type of window. Which I am also interested in knowing what I can do with it.
Sam Hobbs
April 8th, 2004, 02:31 PM
Originally posted by Shino
Sorry if I was unclear, as I read the rules, it says not to make a new post if a post similar was already posted.I am not sure about what the rule is trying to say, but one thing we try to encourage is to look for previous answers. It is quite likely that the rule is trying to say not to ask a question again if there is already an answer.
However I am not a moderator nor do I speak for the management. So please interpret what I am saying in that context. I have seen thousands of threads (discussions) but that is the only thing that might qualify me for saying what I am saying. However what you are saying is that you are trying to do the right thing and I believe you.
Shino
April 8th, 2004, 02:46 PM
thx
RussG1
April 8th, 2004, 05:31 PM
Originally posted by Shino
Is it possible to list all controls of a window? Like listing every available listbox, editbox, menu's, etc.. ?
It is hard to explain but, not everything you see in a window is a "control", even if it looks like one, or is interactive.
Imagine drawing text to a memory device context, and then using BitBlt to copy the contents of the memory dc to the screen so you can see it. The contents of the screen is just a bitmap, thus if the programmer has not implemented some way of storing the text that was used to draw in the memory dc, and a method to later retrieve that text, there is no simple way to get the text from that window. You can even take this one step further and allow typing into the window. The program handles the keystroke and draws something in the window (maybe draws the character represented by the key that was pressed, or maybe it erases another character, or just moves the cursor, etc). This gives the appearance that it is a control, but it really is not. It is just drawing in the window based on input (all handled by the programmer). You can take this even further (add hotspots that when clicked,allow you to tyoe something at a certain spot witin the window, etc), and it may appear that there are multiple controls within the window, but if you try to find the children of this window, there are none. This does not just apply to text, but to the fact that the whole thing is just one window. If the programmer to not create this window as a control, and create methods (messages that can be sent to the window) to do various things within the window, you will not be able to easily access the data within the window externally from the program (other than a screen capture).
Also, read about COM, and ActiveX, etc, as some controls, may have COM interfaces, to access functions that manipulates data within thier window. I do not know enough information about it to give a good explanation, but take for example a web page in Internet Explorer. The web page has lots of properties (background color, etc), and can contain many elements (tags that do different things, like allowing input, showing images, etc). A text area (where you can input text) for example, looks and acts like a control, but will not show up as a child window of Internet Explorer, but you can access it's data using Active Accessiblity and though a COM interface. You can pretty much access anything on the webpage, and change various properties of the web page this way. Again, I really do not know that much about COM. I have only played around with it a little but I have been able to do things like enumerate all of the input areas contained within a webpage, and get the name associated with them, and ID, and the text, etc. I was only able to do this because the IHTMLDocument2 interface is fairly well documented. The window you are trying to get information from, even if it has a COM interface, that interface may not be documented, and thus it may not be easy to figure out what functions are implemented, etc.
In any case I am just trying to get the point across that the window you are looking at, may not actually contain any controls (probably does not, if you do not see there windows in Spy++). You might still be able to do what you want if it has a COM interface (and if you can figure out what is implemeted through that interface, etc). You would have to do some research to figure it out (or maybe use a tool like the previously mentioned ACC Explorer, (if it works as described, and you can figure out what it is and where to get it... I do not know anything about it ).
Shino
April 8th, 2004, 09:20 PM
Russ: Where can I find ACC Explorer?
RussG1
April 8th, 2004, 10:04 PM
Originally posted by Shino
Russ: Where can I find ACC Explorer?
Active Accessibility 2.0 Software Development Kit Tools (http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3755582A-A707-460A-BF21-1373316E13F0)
I do not know anything about that program as I have not used it as of yet, but you can get it at the above link.
Shino
April 8th, 2004, 10:57 PM
Russ: Thanks buddy ! :D
RussG1
April 12th, 2004, 03:40 PM
Shino,
While surfing the net, I came across a Codeguru article that might be of interest to you (as it relates directly to accessing the contents of DirectUIHWND from MSN/Windows Messenger).
Here is the link:
COM Interface Hooking and Its Application, Chapter I (http://www.codeguru.com/Cpp/COM-Tech/activex/tutorials/article.php/c5563/)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.