?
Solved

How to identify and control Control in other Windows?

Posted on 2004-08-01
10
Medium Priority
?
183 Views
Last Modified: 2010-04-05
My problem is, I have to write a program, using Delphi, that can automatically fill-in the form on other application, that application that I'm not the one who wrote. I have clarify the step like this:

1. I have to be able to identify the active form, to ensure that I fill-in the data on the right form. It's simple to get application's title, but how can i know which form is active? I can now get the handle & class of activeform, but handle may not be the same everytime and class may be duplicate. Is there any suggestion? If you can answer the other 2 questions, it might help solving this one as well. I get an idea that if I can get the list of all control in the form, I may be able to compare the list of all control to identify the form.

2. I have to be able to identify all controls in other windows. So, I can select the right control to fill-in data. I can get the active Control's handle & class, but there's no way I can distinguish 2 controls of the same classes (for example, if there're 2 editbox on the form, I don't know which is which.)
3. I have to be able to send data to that particular control. (I think SendKeys can be used, but first, i have to be able to setfocus on that specific control. Is there any more reliable way to setfocus on control rather than generate Mouseclick event? on specific spot?)

Sorry that my question seems to have sub-question, but I can't distinguish them otherwise you may not understand the whole picture.
0
Comment
Question by:kittichai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
10 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11691338
download a program called Greatis WinDowse. Run the other application that was not written by you and point with the cursor on the Edit (for e.g.) you want to change. With WinDowse use see the name of the control, it's class and parents etc.

Then using FindWindow and FindWindowEx you can find the control and using WM_CHAR sent the data you want to write inside.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11691344
0
 

Author Comment

by:kittichai
ID: 11695243
Ivanov_G, my problem is, I have to create the same program as Greatis WinDowse. I have to create the designer that user can design the form filling on any application. I don't want a tool, I want code. My program should do what Greatis Windowse do transparently from the user.

Thank you.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11701030
sorry, I didn't understood what exactly you need. I can not help with code that will be helpful for you.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 11712154
hello  kittichai , ,  you ask
"if there're 2 editbox on the form, I don't know which is which?"
if you have the Handle of a windows control, and want to furthur distingish it from another control of the same class (like EDIT), , I would do in one of two ways, I think that you can get the location of the control with GetWindowRect(HandleOfControl,  ARect);, , so get the location of both edits and then pick the one below the other ot to the left of the other, for the most part  controls in most apps stay in the same relative position, even during resizing, another  way would be to get the text in the control with   GetWindowText( ) and then choose the control from that, but that may be unreliable for an EDIT control,
and some controls have an ID number, which may could help you
0
 

Author Comment

by:kittichai
ID: 11712234
Slick812,
I want the way to identify and distinguish eash contol. The rectangle you suggest is already one of my solution, but it is too unreliable since many windows application may adjust its position when the form resizing. (i.e. any form with splitter may change the position oftenly) It's too unreliable, also the same for your GetWindowText. Isn't any other way to uniquely distinguish & recognize each control?
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 2000 total points
ID: 11719620
if you are out side of that application running process (as you describe) then you can get the stadard  API functions Information for a control windows Handle, and some of these you have already used. . But the process that is useing those controls will just use the Creation returned  HANDLE  for that control to "Identify" it, so many times there is NO OTHER identifier set up for that control, since that program's code does not need any furthur way than the Handle to use and change that control. As I have mentiond before, , some programmers (like me) will give all of their control a number control ID, since thare id a number used for the windows ID (if control) in all of the creation functions (this programming is outside of the Delphi VCL, which does not include any way to set the ID of a control)

you can use the   GetWindowLong( ) functio to get an ID number from a window that has one. .

. . . something else. .  I believe that the findwindowEX will cycle through the controls in the order that they were created in that window, so I would guess that you can just get the "Order" of the controls handle in the FindWindowEx search, in other words, the first edit in that search will always be the same edit, and the second edit in that search will be the same edit control, for any search that is done, but I could be wrong in how I remember that asspect of this for FindWindowEX
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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