Uniquely identify a control in any Winodw using Object Name.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am developing scripts in C# which can be used to test windows based
applications. I use Win32 API's to perform click operations etc. To uniquely
identify a control in a window rather than using absolute position of a
control I have been using Control-ids and captions of the control. But I
found scenarios where the control-id was dynamic and the control didn't have
a caption. What I mean by caption is the text of the control. A control, say
a button can have both name and text - Name: btnOk and Caption: OK. What I
hoping to get is the Name "btnOk" that can uniquely identify it in a window
because no two controld can have the same name, but it can have the same
caption. I have searched through the Win32 API's and I have been able to find
a suitable API that does the job. Any kind of help will be appreciated.
Thanks a lot.
 
I am developing scripts in C# which can be used to test windows based
applications. I use Win32 API's to perform click operations etc. To uniquely
identify a control in a window rather than using absolute position of a
control I have been using Control-ids and captions of the control. But I
found scenarios where the control-id was dynamic and the control didn't have
a caption. What I mean by caption is the text of the control. A control, say
a button can have both name and text - Name: btnOk and Caption: OK. What I
hoping to get is the Name "btnOk" that can uniquely identify it in a window
because no two controld can have the same name, but it can have the same
caption. I have searched through the Win32 API's and I have been able to find
a suitable API that does the job. Any kind of help will be appreciated.

So far as I know, you're out of luck. It's been a long time since I
used CreateWindow, but if you look at the API dox, the lpWindowName
parameter is not really a name: "When using CreateWindow to create
controls, such as buttons, check boxes, and static controls, use
lpWindowName to specify the text of the control."

That is, the concept of unique name is a function of the wrapper
libraries (WinForms, VB, Delphi's VCL) on top of the Win32 API.
 
Back
Top