I saw some ideas here but I'm not sure how to/if I can use them with AutoHotkey:
javascript - Check if element is visible in DOM - Stack Overflow
https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
Checking the element's position would be a workaround, but I'm looking for a better way. Sometimes some elements' widths/heights are set to 0 when hidden, but AFAIK not in this case.
Thanks for reading.
Code: Select all
;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869
;e.g.
;Google Translate
;https://translate.google.com/translate?sl=de&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=https://autohotkey.com/boards/viewtopic.php?f=11%26t=9798&edit-text=&act=url
;original link:
;'Echte' Arrays - Grundlagen - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=11&t=9798
q:: ;google translate - toggle hide/show bar, focus frame
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
oWB.document.getElementById("clp-btn").click()
;IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
;VT_DISPATCH := 9
oDoc := ComObject(9, ComObjQuery(oWB.document.parentWindow.frames[0], "{332C4427-26CB-11D0-B483-00C04FD90119}", "{332C4427-26CB-11D0-B483-00C04FD90119}"), 1).document
oDoc.documentElement.focus()
oWB := oDoc := ""
return
- It may be that the control isn't hidden, and that it is has been pushed above the visible area. Is that common? I could check whether certain position values are negative or not.
Code: Select all
;before:
oWB.document.getElementById("clp-btn").click()
;after:
oElt := oWB.document.getElementById("gt-appbar")
if (oElt.getBoundingClientRect().top > 0)
oWB.document.getElementById("clp-btn").click()
- One approach in this case would be to query the button that I send a click to, which has either an up arrow or down arrow appearance.
Code: Select all
;before:
oWB.document.getElementById("clp-btn").click()
;after:
if !InStr(oWB.document.getElementById("clp-btn").className, "clp")
oWB.document.getElementById("clp-btn").click()