Detecting assistive technology on Windows

Hello

I noticed that LibreOffice supports assistive technology (AT) and that in order for LibreOffice to expose its information it must detect the presence of AT.

I have looked through the wiki and found this page: LibreOffice Accessibility Resources - The Document Foundation Wiki where it explains what I just said. It does not explain what LibreOffice looks for specifically though.

I am developing dictation software and need to know the text and caret position in a document. Through IAccessible2 this is possible but I do not know how to let LibreOffice know that my AT is active.

Did you already enable the respective option under Tools>Options>LibreOffice>Accessibility?

I did, yes. It was actually enabled by default.

Sorry.
(I hope you won’t expect the next answer by me now. I never used “AT”, and only hinted to a very simple probable error. - Yes this kind of errors often occur.)
By the way: I would like to know what, exactly, you address as caret position in your question. Is it related to the .Position property of the ViewCursor?

I’m trying to use IAccessible2, specifically caretOffset to gain the caret position in relation to the text surrounding it.

Using various inspection tools (aViewer and AccProbe) i have been unable to gain anything from LibreOffice. I am suspecting that this is due to LibreOffice not thinking the aforementioned tools are “AT”. Which leads me back to my question of how I am supposed to let LibreOffice know when an “AT” is in use.

For instance, I know that Chrome does the following:
Chrome calls NotifyWinEvent with EVENT_SYSTEM_ALERT and the custom object id of 1. If it subsequently receives a WM_GETOBJECT call for that custom object id, it assumes that AT is running.

(Still not about helping. Just for curiosity.)
I just read about the caretOffset routine. Let me assume that the child text objects mentioned there not need to be taken in account as far as LibreOffice is concerned. At least I put them aside for now.
Then I need to understand what the text should be in your case. Text objects called by this name in Writer belong to the overall document (bodytext then), to frames, to TableCells, or to shapes. In Calc it can be a shape again, but mostly it will be a cell. In the given context, however, the text object should be somthing different, I suppose. Can you quench my curiosity?

The text should be the text surrounding the caret. IAccessible2 returns the focus of which the caret is placed enabling me to get the text from the focused object. This should return the text in context with the caret and not frames or otherwise as they are not the focus point.

It works intentionally in both Chrome, Firefox and Opera. I’m still struggling with LibreOffice.

Hope this is somewhat quenching.

Believe apps need to HWND_BROADCAST to emit SPI_SETSCREENREADER to be seen as AT, including your effort. [1]

You can force that mode by launching LibreOffice with the flag “SAL_FORCE_IACCESSABLE2=1” [2] for apps that do not.

For determining IAccessible2 support, LibreOffice will issue HasAtHook() to read system SPI_GETSCREENREADER status. [3]

Should get your app connected. What I don’t know is if the text and caret positions would be exposed for the TEXT role(s) we use.

=-refs-=
[1] https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfow
//beleive the systemparametersinfoa is per user flavor
[2] https://opengrok.libreoffice.org/xref/core/vcl/source/app/svdata.cxx#327
[3] https://opengrok.libreoffice.org/xref/core/vcl/source/app/salplug.cxx#351

This was exactly what I needed. Thank you very much!