Focused element for mail/notes app

I want to get the content present in a note or a mail thread when my cursor is in it on macos. (In the focused element).

But I don't succeed to get any element from both mail and notes using :

let result = AXUIElementCopyAttributeValue(appRef, kAXFocusedUIElementAttribute as CFString, &focusedElement)

Even when I want to check the available attribute :

    let result = AXUIElementCopyAttributeNames(element, &attributeNames)

I got AXUIElementCopyAttributeNames result: AXError(rawValue: -25204)

But I have the write permission because when I am running AXIsProcessTrusted() to see if I got accessible permission it don't throw an error

Is it possible to do it that way or I have to change

Focused element for mail/notes app
 
 
Q