IDispatch htm(tag name [html] [window] [frame] [index] [flags] [waitS] [navig])
IDispatch htm(hwnd)
IDispatch htm(acc)
tag - tag. Example: "A".
name - text. Depending on flags, it also can be some attribute. Can be "".
html - outer html. Example: "<A href="http://www.x.com">Name</A>". Default: "" (any).
window - window with web page ("Internet Explorer_Server" control) that contains this element.
frame - 1-based index of frame/iframe. Or path to it, like "2/3".
index - index of this element in collection of elements of tag type.
1 | name is full or with wildcard characters (*?).
|
2 | name is regular expression. |
4 | html is full or with 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 | Error if not found. |
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. |
waitS - time (seconds) to wait for the element in the window.
navig - a positive or negative number that can be used to get an adjacent element.
hwnd, acc - read in Remarks.
Finds a html element.
Returns pointer to MSHTML.IHTMLElement interface (except Syntax2), or 0 if not found. The return value can be assigned to a variable of type Htm. The variable represents a html element, and is used to manipulate it (click, get text, set text, get other interface, etc).
A html element is an object in a web page (link, button, text, 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.
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 pass the window handle to htm as window.
Returns pointer to MSHTML.IHTMLDocument2 interface of web page in window hwnd. If hwnd is literal 0 - in first matching window. The interface represents web page, which is container of html elements.
Tips: To get html document from html element, call element's document property. To get MSHTML.IHTMLWindow2, call document's parentWindow property.
Gets html element that corresponds to accessible object acc.
Tip: Function acc can be used for backward conversion.
Tip: To get html element from certain coordinates, use acc: Acc am=acc(x y hwnd); Htm hm=htm(am). It works withs some elements (e.g. links, images, input) but does not work with others (e.g. simple text).
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 match, 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