- Here's the sort of investigation/experimentation I do, to identify the right web element in Internet Explorer:
Code: Select all
;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869
;note: getElementsByClassName/getElementsByTagName methods [elements plural]:
;you can loop through elements with a particular class/tag, and check info on them to find the right one,
;or get the nth element (0-based index) with a particular class/name if the index is consistent
;note: getElementById method [element singular]:
;you can get direct access to an element if it has a unique ID
;note: getElementXXX methods
;you can find an element via a getElementXXX method,
;and then search through its elements by using a getElementXXX method,
;i.e. find an easily identifiable element to narrow down the search
;note: parentElement and childNodes properties
;these can be used to navigate to/query parent/child elements
;note: getAttribute
;this can be used to retrieve an element's attribute or a blank string, without crashing AHK,
;alternatively you can use try and catch
q:: ;Internet Explorer - click button
WinGet, hWnd, ID, ahk_class IEFrame
oWB := WBGet("ahk_id " hWnd)
vEltClass := "btn btn-success"
MsgBox, % oWB.document.getElementsByClassName(vEltClass).length
oElt := oWB.document.getElementsByClassName(vEltClass)[0]
MsgBox, % oElt.innerText
MsgBox, % oElt.outerHTML
oElt.click()
oWB := ""
return
- Similar logic may be applicable to other web browsers.
- To automate Firefox/Chrome you could consider:
[Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium! - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=42890
Using Selenium with AutoHotkey- Cross browser automation! - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=32323
- Use iWB2 Learner to investigate IE tabs (zoom must be set to 100% for the box outlines to align correctly). Download here:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
- There is some other similar information here:
Help with ControlSend (or Control) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=50499