Mr. Cluey
: How To ...? : QAP TagsQA Partner uses tags to identify particular instances of window classes. Most of the time, script writers don't need to worry about the where and whys of tags - just code using the identifiers in the window declarations.
Most of the time isn't always good enough.
When the Record Declarations window is invoked, it typically records up to 5 different strings which can be used as the tag for the window.
Captions are easily the most common, and most intuitive, of the window captions. Captions are also the default catagory of tag, and as such take no prefix at all.
You can get the caption of a window at runtime by using the GetCaption() method.
Prior text tags are generally used when the window itself does not have text on it. Typically text fields, list boxes, combo boxes and the like may end up using the text of some nearby control for a tag.
Prior text tags are marked with the ^ prefix. The actual text is obtained using the GetPriorStatic() method.
Index tags are usually used for windows that don't have text associated with them. Alternatively, they get used when the text is likely to be changing at run time.
Index tags are marked with the # prefix. The actual text is obtained using the GetIndex() method.
Window IDs, quite frankly, aren't usually used. I needed them to identify HTML frames in the pre-silk world. But beyond that, the only implementation I have seen that uses them is the MessageBox declaration, which identifies the window as DialogBox("$0").
As the messagebox declaration demonstrates, the prefix for the window ID tag is $. GetID() will hand you the rest of the string.
When you are really stuck for options, you can fall back on the location tag. This one takes a little more work.
The location tag is written with the @() marker. The actual text of the window is the X,Y coordinates of the center of the window. The coordinates are measured relative to the parent of the window. Suggest anything?
You bet! It's GetRect() to the rescue. To build the tag on the fly, its helpful to store the rect in a local variable, like so:
RECT r = w.GetRect() ;
WNDTAG wt = "@({r.xPos + r.xSize/2},{r.yPos + r.ySize/2})" ;
| Mr. Cluey : How To ...? : QAP Tags |