I would like to assign, programmatically, a macro to a function key (instead of changing manually this assignation).
How could I do this ?
The way to do something like this is to add a key handler to ThisComponent.CurrentController
using the addKeyHandler() method. This makes it possible to intercept the keystroke and then cancel it so that it doesn't do whatever else the key was assigned to.
There is an example at https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=33914.
Write a macro that adds the listener, like sStartXKeyHandler
in the example. Then assign that macro to a document event such as OnLoad
.