IDispatch htm(tag name [html] [window] [frame] [index] [flags] [waits] [navig])
IDispatch htm(hwnd)
IDispatch htm(acc)
tag - element's tag name (e.g., "A" for anchor).
name - element's text. Depending on flags, it can be some other attribute. Can be "".
html - element's html code (e.g., "<A href="http://www.quickmacros.com">Name</A>"). Default: "" (any).
window - window with web page ("Internet Explorer_Server" control) that contains this element. If omitted or 0, is used first (in the Z order) visible Internet Explorer window (class "IEFrame") or other browser window (class must be specified in Options).
frame - 1-based index of frame, or path to frame (e.g., "2/3"). If "0", element must be not in frame. Default: "" (any frame or not in frame). This argument reduces search time in multi-frame pages. Used only with IE 5.50 and later.
index - index of this element in collection of elements of tag type. It significantly reduces search time. It may not match exactly (e.g., after page structure has changed), but then search time is longer. If tag is "", index is index in collection of all elements. Default: 0.
flags - combination of the following values. Default: 0.
| 1 | name must match exactly or may contain wildcard characters (*?). String "*" matches elements with no name. Without this flag, name can be partial. This flag cannot be used with flag 2. |
| 2 | name is regular expression. |
| 4 | html must match exactly or may contain wildcard characters. This flag cannot be used with flag 8. |
| 8 | html is regular expression. |
| 16 | window is handle of "Internet Explorer_Server" child-window. Default: main window. If not set, the function searches only in the first visible "Internet Explorer_Server" control. |
| 32 | if element not found, generate error. |
| 0x100-0xA00 | name is attribute: 0x100 - id, 0x200 - name, 0x300 - alt, 0x400 - value, 0x500 - type, 0x600 - title, 0x700 - href, 0x800 - onclick, 0x900 - src, 0xA00 - classid. |
| 0x1000 | store "Internet Explore_Server" child window handle into variable tls9. |
waits - max number of seconds to wait until the element will appear in the window.
navig - positive or negative number that can be used to get an adjacent element.
hwnd, acc - see remarks.
Finds a html element. A html element is an object in a web page (link, button, text, etc). The return value can be assigned to a variable of type Htm or IHTMLElement (defined in MSHTML type library). The variable represents a html element, and is used to manipulate it (simulate click, get text, set text, get pointer to other interface, etc).
Html elements is faster and more precise alternative to accessible objects. However, this function works only with Internet Explorer and other windows that display web page in "Internet Explorer_Server" control.
Finds html element. Returns pointer to IHTMLElement interface, or 0 if not found.
The function searches only in the first found matching window, and only in the first found visible "Internet Explorer_Server" control that displays a web page. To search in other windows or controls (for example in hidden tabs), find the window (win) or control (child) and use the window handle with htm as the window argument.
Returns pointer to IHTMLDocument2 interface of web page in window hwnd. If hwnd is 0 (constant) - in first matching window. IHTMLDocument2 interface represents web page, which is container of html elements. To get html document from html element, call element's document property. To get IHTMLWindow2, call document's parentWindow property.
Returns pointer to IHTMLElement interface that corresponds to accessible object acc. Function acc can be used to do backward conversion.
To insert the htm function, use the Find Html Element dialog. Drag the picture and drop onto an object in a web page. This fills the dialog with values that are optimized for best performance.
If the web page is frequently updated, element's index may change, and for some elements this may cause the function to find another similar element. To minimize this possibility, you should test (press the Test button) with different Index. Test with index 0 and index 10000. If then will be found different element, try to change some parameters, or find an adjacent element and use Navigate (positive or negative number) to navigate to the desired element. Also, if index does not mach, the search time is longer. It is as longer as the count of elements in the Tag collection is larger, so you may consider to find an element that belongs to a tag with less number of elements, and then navigate.
In the dialog, the Index in all field is index of element in collection of all elements in page or frame. Normally, it isn't used with htm function. Click arrows to view adjacent elements. Or, type another index and press ! (update).
To manipulate a html element (click, get/set text, etc), use the Html Element dialog. Alternatively, type . after variable name, and select a function from the drop-down list.
Htm el=htm("INPUT" "id" "" "Internet Explorer" 0 0 0x221) el.Click or el.el.click or MSHTML.IHTMLElement el=htm("INPUT" "id" "" "Internet Explorer" 0 0 0x221) el.click