How to use Python3-uno to capture help texts?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

How to use Python3-uno to capture help texts?

Post by MiguelTeixeira »

Hi,

I wish to capture help texts from the OpenOffice interface when they appear (this would be when the mouse hovers over a button/option ..) but I am having difficulty with the documentation (https://wiki.openoffice.org/w /images/d/d9/DevelopersGuide_OOo3.1.0.pdf).

In fact, I would also like to know if this is possible.

I am here looking for a way. Some direction within the documentation, or some help in the form of code example.

At the moment, that was as much as I could get:

>>> import uno
>>> contexto = uno.getComponentContext()
>>> resolver = contexto.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", contexto)
>>> serviceManager = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager")
>>> ht = serviceManager.createInstanceWithContext("com.sun.star.awt.UnoControlButtonModel", contexto)
>>> ht..HelpText
''
This is far from what it has to be. I don't even know if I'm on the right track. The truth is that I was a little frustrated reading the documentation. :/

thanks for helping!!!!!
Last edited by MiguelTeixeira on Sun Aug 11, 2019 8:57 pm, edited 2 times in total.
MX Linux, LibreOffice 6
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to use Python3-uno to capture help texts?

Post by JeJe »

I don't know Python but if by 'capture help texts' you mean set the help text to a string of your choice - then its a trivial thing to do with the BASIC ide or in code... yourbutton.model.helptext = "blah blah"

https://www.openoffice.org/api/docs/com ... Model.html

Edit: perhaps this link will help

https://wiki.openoffice.org/wiki/Danny.OOo.DialogLib.py

from https://wiki.openoffice.org/wiki/Danny% ... on_Modules
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: How to use Python3-uno to capture help texts?

Post by MiguelTeixeira »

Hi,

Thanks for your reply! I will check your links already (including, analyzing quickly, they seem really useful).

What I want is to get the HelpTexts in real time, while the user navigates through the OO options.

Code: Select all

while(True):
     time.sleep(1)
     print(RealTime.HelpText.Of.User)
For example, when the user hovers over the "Save" option (and the option's HelpText is displayed), I want to get the option's helptext. I am developing my code in Python, but if anyone knew how to do something close to this in C ++, it would also be of great help.


Thanks a lot!!
MX Linux, LibreOffice 6
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to use Python3-uno to capture help texts?

Post by RoryOF »

It might be simpler to get the texts from the separate application help files; on my computer these are in /opt/openoffice4/help/en/swriter.db (and similar names for the other applications). There are other files associated with these, such as indexes etc, but those may not be relevant.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: How to use Python3-uno to capture help texts?

Post by MiguelTeixeira »

Hi,
Thanks for your reply!

The point is, it's not about getting all the help texts and saving them in one specific place. It's about identifying them when they appear in the OO (or LibreOffice) interface.

But I will check the tip you gave me and try to think of a way to adapt my project.

Thanks for your helping!
MX Linux, LibreOffice 6
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to use Python3-uno to capture help texts?

Post by JeJe »

You might need to rewrite the Office suite itself to do that.

I'm on Windows OS... Using an external program to Enumerate all the top level windows ... the help text popup looks to be a Window with the class name SALTMPSUBFRAME. Using SendMessage with WM_GETTEXT unfortunately doesn't return the help text string though... if it had done you could have written an external program to wait for that class of window appearing and then get the text.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: How to use Python3-uno to capture help texts?

Post by MiguelTeixeira »

Thankssss JeJe. This information was very helpful. But now I'm getting sad.

That is the question,

I rewrote some LibreOffice files and am capturing help texts via:

- vcl / inc / helpwin.hxx
- vcl / source / app / help.cxx

Reading strings through an external program and doing what I want (displaying Gifs instead of help text when they appear).

I am wondering if there is an "easier" way to do this that does not require me to change LibreOffice Core every time new versions are released. This would be possible if my app was a plug-in. In this case, it would also be a plugin / extension for OpenOffice.

My app already uses UNO for a Calc formula wizard. But I would like to make it a complete plugin, and without the need for LO/OO Core changes.

https://youtu.be/DVAWjRV0dTw
MX Linux, LibreOffice 6
Post Reply