Hi - newbie here!
I'm currently using a trial version of the software to determine whether to proceed with it.
We provide Genero/Informix based database software which is very customer bespoke. We have many clients who use many "generic" features of our software, but we have quite a few customers who have a basic generic system which is tailored to meet their own specific requirements.
Therefore, what we have are some clients who have certain textboxes on their forms, whereas other clients do not have these textboxes at all - indeed, they might even have textboxes that are exclusive to themselves. As you can imagine, this makes the automation of testing a nightmare.
What I want to do is write script which can determine the 'name' of the textbox control, and act accordingly - so, for example, by pressing tab to move to the next field, it can use the 'name' and run a section of script applicable to the 'name' of the text box.
Is it possible to return the name of the control and work with it?
Determine control name
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 3
- Joined: Fri Feb 02, 2007 10:58 am
- Location: Wigan, England
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
As far as I am aware this isn't possible. Objects publish their class names and handles, but they don't have a name beyond how they are identified in the source code of the application. At run time, that name would be no use to an external process.
You can get the handle, class name and caption text but there's really no such thing as a "name" as far as Windows is concerned at the presentation layer. The handle changes each time, and if you have several items with the same class name, and the amount varies each time, this doesn't help either.
If it is possible to initialise the form so that each field had a unique value, you could then identify each control based on those initial values using FindWindow/FindWindowEx. Once identified, and the handles obtained, the initial values can be changed.
You can get the caption text of labels. So if each field has a label and you can predetermine where the edit box appears in relation to the label, and you are able to retrieve the X,Y position of the label ... then you could be on to something. But even if possible, this is going to be hideously difficult, especially if you are not used to scripting and using the Windows API.
An easier solution might be a graphical approach using the image recognition functions. If you capture images of each of the labels and build in offsets for the associated edit boxes you can a) determine if the label exists on the window, and b) identify the position of the associated edit box. Use the image recognition functions to "see" what's on the screen and retrieve object positions:
http://www.mjtnet.com/imagerecognition.htm
You can get the handle, class name and caption text but there's really no such thing as a "name" as far as Windows is concerned at the presentation layer. The handle changes each time, and if you have several items with the same class name, and the amount varies each time, this doesn't help either.
If it is possible to initialise the form so that each field had a unique value, you could then identify each control based on those initial values using FindWindow/FindWindowEx. Once identified, and the handles obtained, the initial values can be changed.
You can get the caption text of labels. So if each field has a label and you can predetermine where the edit box appears in relation to the label, and you are able to retrieve the X,Y position of the label ... then you could be on to something. But even if possible, this is going to be hideously difficult, especially if you are not used to scripting and using the Windows API.
An easier solution might be a graphical approach using the image recognition functions. If you capture images of each of the labels and build in offsets for the associated edit boxes you can a) determine if the label exists on the window, and b) identify the position of the associated edit box. Use the image recognition functions to "see" what's on the screen and retrieve object positions:
http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 3
- Joined: Fri Feb 02, 2007 10:58 am
- Location: Wigan, England
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
I wasn't suggesting that you DO rely on the position of labels. What I was saying was that based on the label CAPTION you can FIND the label and RETURN it's position and therefore determine the EDIT field position. This could be done using image recognition, or possibly, with more complicated Windows API.
I am not saying that your script uses absolute positions, but rather it FINDs the positions to find the edits. Perhaps my last post was not clear.
I wasn't suggesting that you DO rely on the position of labels. What I was saying was that based on the label CAPTION you can FIND the label and RETURN it's position and therefore determine the EDIT field position. This could be done using image recognition, or possibly, with more complicated Windows API.
I am not saying that your script uses absolute positions, but rather it FINDs the positions to find the edits. Perhaps my last post was not clear.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 3
- Joined: Fri Feb 02, 2007 10:58 am
- Location: Wigan, England