Spy++ or Windows Api Functions not locating controls on child window

I'm trying to write a console application in C# to manipulate another 3rd party Windows application our company uses (written in FoxPro). I'm not seeing all controls on a child page with spy++ or through C# code calling Windows API functions such as FindWindowByIndex() method. Are their some Windows programs that hide controls or that are just written in such a way that they're not accessible, or are their other ways to find them programmatically? My code (using the above and other methods like FindWindow(), FindWindowEx(), etc.) is locating ONLY the same windows/controls that spy++ can see. The window I need to manipulate contains some 50 check boxes, buttons, panels, etc., though Spy++ shows only a few 'next' windows that contain a few dead-end child windows. If I place the finder tool over that windows controls - nothing changes!

Please clue me in on anything (tools, code, shrink, ...) you can think of to find these controls or any info on what may cause these not to show up. I need to know when it's time to stop trying if this is really not possible. Thanks!
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.

Mike TomlinsonMiddle School Assistant TeacherCommented:
"Are their some Windows programs that hide controls or that are just written in such a way that they're not accessible..."

Absolutely!  There is the notion of a "light" or "heavy" control.  A light control does NOT have it's own window handle and won't be seen by Spy++ (or other similar utilities).  The manipulation of a light control is much more difficult as you usually have to start poking around in the apps memory space to find them.  A heavy control has its own window handle and can receive messages directly.  Some applications use all light controls, others all heavy controls, and some use a combination of both.  (I believe both MS Access and FoxPro use all lightweight controls.)

User interfaces that are browser based in nature (Internet Explorer for example) would be considered completely "light" but are technically something completely different.

On the new technology front, WPF (Windows Presentation Foundation in .Net 3.0 and above) apps draw their interfaces not unlike a game drawing to the screen with OpenGL/DirectX.  So you'll find that apps using WPF don't present you with any handles either...
bfay65Author Commented:
Idle, Thanks for the fast reply!  Looks like you might have been cut off, or were you finished? Your last line looks like this:

So you'll find that apps using WPF don't present you with any handles  either...

I need to know more about how to handle this if it is in fact 'lightweight'.  There was a window blocking, but when I opened the app more and moved the child window out of its scope, spy++ gave it only 1 handle for the whole window.  So how do I 'start poking around in the apps memory space to find them'?  How could I deal with the controls if they're in a group box or 'inside' of some other control - like a grid?  Could that also be the case? How would I know that was the case?  so many questions!  Thanks!
Mike TomlinsonMiddle School Assistant TeacherCommented:
It's possible to do but way beyond my level of programming...it would require un-managed code to say the least.  =\

Another option is to attempt to automate the process by blindly sending keystrokes with SendKeys.Send() but this is an un-reliable approach at best.

A third approach would be to try a third-party tool such as AutoIt:


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
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

bfay65Author Commented:
Idle, Thanks for the suggestions.  I'll may have to try a 3rd party tool, but would like to first prove I can't get to these controls any other way.  I started out using the keystrokes, but found that some fields on this window became inaccessible if 0 orders were shown in a label there, which throws off the number of tabbing needed to access other check boxes.  Therefore; to do what I need, I must access and read that zero in order to proceed (since the process needs to loop hundreds of times and hit the right controls each time.  

Anyone have suggestions on how to prove if either these are in fact 'Lightweight Controls' or if they are wrapped in some other type of proprietary or otherwise-limiting control?
bfay65Author Commented:
So to rephrase...What steps does one take to automate an application when spy++ does not see the controls you need?  Since the tabbing routine changes depending on the data in the controls, simple SendKeys patterns won't work.  I will need to see the data in the labels and checkboxes to control the steps.

Possible issues:
1. The controls are 'lightweigt' and therefore virtually inaccessible (but how can I tell?)
2. The controld are 'wrapped' or 'nested' in another control like a panel (What then?  Win API functions i.e. FindWindowsEx() aren't finding child windows)
3. Please suggest other reasons these won't show up and/or what to try next

Mike TomlinsonMiddle School Assistant TeacherCommented:
Basically if Spy++ doesn't show a handle then it is lightweight and I don't know how to access it.  Sorry...  =\
bfay65Author Commented:
Auto-IT worked well enough to automate the program, though I was really hoping someone could help me figure out how to identify and read the controls on the page, Idle's suggestion was the only suggestion and he helped me get this solution going.  Thanks Idle!
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

From novice to tech pro — start learning today.