Solved

Control References

Posted on 2006-07-18
8
228 Views
Last Modified: 2010-04-16
How do I get a reference to a control on an application separate from the one I'm writing (non-Microsoft, meaning not MS Word, etc.)?

Here's what I need to do...
1)  Get a list of all Windows applications running (all visible).
2)  Get a list of controls from a particular application (selected from #1 above).
3)  Get a reference to one of the controls in #2 above.
4)  Get and set the value in the control.
5)  Keep track of which control has focus.

Thanks for any suggestions!!
0
Comment
Question by:scottmichael2
  • 4
  • 2
8 Comments
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 150 total points
ID: 17129831
For .NET applications you can use Managed Spy Library:
http://msdn.microsoft.com/msdnmag/issues/06/04/ManagedSpy/

For unmanaged applications you need to write this in unmanaged C++ or using PInvoke API calls from C#.
0
 
LVL 1

Author Comment

by:scottmichael2
ID: 17131324
Does anyone have an example of doing this is C# (for unmanaged apps)?  I believe most of what I'm dealing with will be unmanaged.  Thanks!
0
 
LVL 3

Accepted Solution

by:
BBK_ earned 350 total points
ID: 17146457
I don't have the sample code for it, but i can guide u


For step1
you can use "EnumWindows" API which will give you all the windows opened in a callback function.

For Step2

You have to iterate thru the selected window only thru the Handle of the selected window in step1

For Step3 & Step4 & Step5
  You can't create an instance of a control,which is in another window, rather it that window is a control that has window Handle then you can manipulate that control's property

eg: if you want to change the text, use windows API SetWindowText().
If the control that you are looking does not have Window handle then you can't acces to that control.

Unless you have the Window handle of any contols, you can't do anything to that.




0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:scottmichael2
ID: 17146793
"If the control that you are looking does not have Window handle then you can't acces to that control."

I guess this means Java apps are out of the question, right?  All I can seem to get is a reference to the parent Window (no children are exposed).  Any ideas on how to tackle this one?
0
 
LVL 3

Assisted Solution

by:BBK_
BBK_ earned 350 total points
ID: 17151549
There is an easy way to find to see a window has a handle or not,

I think you have Spy ++ application in your machine(Which comes with Visual Studio).
Using this we can find the Controls inside a window.

You try with Spy++, that will give you a good understainding about the Child window and it's handle
0
 
LVL 1

Author Comment

by:scottmichael2
ID: 17186854
It looks like Spy simply gives you the parent Window information.  Nothing internal seems to be captured (just the parent hwnd and global mouse, keyboard info).
0
 
LVL 1

Author Comment

by:scottmichael2
ID: 17186866
Let me clarify that last post - this seems to be true with Java applications.  With Windows applications I can get the hwnd of the individual Windows as well (such as controls).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Handling arrays 14 35
Problem with SqlConnection 5 123
Converting C# Objects into JSON file 7 41
Data Saving 5 40
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now