简体   繁体   中英

Autoit FF.au3 cant check if element is focused

How can I check if the element is focused?

This is my try:

I have prepared a function that checks if the object is focused:

_FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}')

$oElm = _FFXPath("//*[@id='someId']")
_FFIsFocused($oElm)

Func _FFIsFocused($sElement = "")
    Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")")
    Return $isFoc
EndFunc   ;==>_FFIsFocused

It never trows TRUE. Seems like the object I'm sending is type XUL object.

Got help from Autoit forum from user Danp2!

The final code is:

_FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === FFau3.WCD.activeElement)}catch(e){return}}')

$oElm = _FFXPath("//*[@id='someId']")
ConsoleWrite(_FFIsFocused($oElm))

Func _FFIsFocused($sElement = "")
    Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")")
    Return $isFoc
EndFunc   ;==>_FFIsFocused

The problem was with document.activeElement that we couldn't access that way since we are doing it from inside the mozrepl. FFau3.WCD.activeElement is to be used instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM