Macro to set a shortcut key?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Macro to set a shortcut key?

Post by JeJe »

Hi, I have created an extension and would like to give the user the option of setting a
shortcut key to run a macro in the extension -- without them having to search
through all their macros in OpenOffice to find it. Which may be a bit much to expect of them.

I have thought of three options

1) supply a keyconfig.cfg file with the extension. Not very slick and would
overwrite existing config, not just add the ones I want.

2) use a menu item with an accelerator instead. Again not slick.

3) edit the keyboard config file. I found this but have OO 4 and things seem to
have changed... there is no current.xml file on my system.

https://wiki.openoffice.org/wiki/Docume ... ation_File

Is it possible to programmatically create a shortcut to run a macro? Or is there
another way to do it?

I ideally want to ask the user "Create shortcut key to do blah blah?", together with suggestions for the shortcut. If they say yes, then run a macro to set the shortcut that will run the macro in the extension.
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro to set a shortcut key?

Post by JeJe »

Sorry, I meant no Accelerators.xcu file at the given locations, not current.xml file
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro to set a shortcut key?

Post by JeJe »

There is one in this folder. I installed the basicidetools extension and the file has the right format

C:\Users\me\AppData\Roaming\OpenOffice\4\user\uno_packages\cache\uno_packages\svfk2mm.tmp_\basicidetools-1.3.0.oxt\Office


<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
oor:name="Accelerators"
oor:package="org.openoffice.Office">
<node oor:name="PrimaryKeys">
<node oor:name="Modules">
<node oor:name="com.sun.star.script.BasicIDE">

<node oor:name="C_SHIFT_MOD1" oor:op="replace">
<prop oor:name="Command">
<value xml:lang="en-US">vnd.sun.star.script:BasicIDETools.BIT_Main.BIT_Comment?language=Basic&location=application</value>
</prop>
</node>

[[[[etc etc etc]]]]

</node>
</node>
</node>
</oor:component-data>


Looking through all the code of that extension I'm guessing how they've done it is somthing to do with
confProvider = CreateUNOService("com.sun.star.configuration.ConfigurationProvider"

Sorry, I'm really new to OpenOffice programming...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply