Autoit FF.au3 cant check if element is focused

210 views Asked by At

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.

1

There are 1 answers

0
Milos On BEST ANSWER

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.