Override shortcuts in Writer

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Tabyria
Posts: 2
Joined: Fri Feb 23, 2018 3:04 pm

Override shortcuts in Writer

Post by Tabyria »

Hi there,

I'm a beginner and simply need to personalise the shortcuts for a few special characters in Writer.

I've followed the steps detailed in this tutorial
https://wiki.openoffice.org/wiki/Docume ... rtcut_keys

However, it only works if the shortcut hasn't been assigned before. So I've managed to create Alt+Ctrl+3 for é for example. However, I can't create Ctrl+Alt+A for à as it seems to be assigned to "á" already (accent the other way round). Same for
Alt+Shift+E which I would like to use for ê but instead it automatically opens Edit.
I've checked under Customise and I can't find these shortcuts in order to delete them and replace. Ctrl+Alt+A looks linked to the macro I've created for à but it doesn't work.

I've spent a few hours trying to sort it out and it's getting really frustrating. I'm sure there's an easy answer. Anybody can help? I'd be very grateful. Thanks!!
Taby
Apache OpenOffice 4.1.5 on Windows 10
JeJe
Volunteer
Posts: 2756
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Post by JeJe »

I get the same result as you and there's a previous thread on this that didn't get solved, so you probably just have to find another shortcut.

(This may be over your head but for anyone who knows this stuff... I tried a keyhandler as well... and that can't do it either - Ctrl+Alt+A returns 0 for the keyboard event modifiers not 6 which it should. )
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2756
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Post by JeJe »

Rethink - yes you can do it with a Keyhandler, using the Keypress
Put this code in a module and press F5 to run the first sub
Then try pressing Ctrl+Alt+a. The message box should show.

Replace the message box with with your macro code.

And add code for you other shortcuts.

You can start the Keyhandler from the document open event.


KeyHandler code from here
viewtopic.php?f=45&t=33914

Code: Select all


Option Explicit

global oXKeyHandler as object

sub sStartXKeyHandler
    if isNull(oXKeyHandler) then 'only if not jet running
        oXKeyHandler = CreateUnoListener("KeyHandler_", "com.sun.star.awt.XKeyHandler")
        ThisComponent.CurrentController.AddKeyHandler(oXKeyHandler)
    endif
end sub

sub sStopXKeyHandler
    if not IsNull(oXKeyHandler) then 'only if still running
        ThisComponent.CurrentController.removeKeyHandler(oXKeyHandler)
        oXKeyHandler = Nothing 'To know later this handler has stopped.
    end if
end sub

sub XKeyHandler_Disposing(oEvent)
end sub

function KeyHandler_KeyPressed(oEvent) as boolean
    KeyHandler_KeyPressed = False 'cancel KeyPressed

WITH oEvent
'msgbox .modifiers
if .keyChar = "á" then
'if .KeyCode = 512 and .Modifiers = 6 then
msgbox 5
KeyHandler_KeyPressed=1
end if
end with
'    MsgBox(oEvent.KeyCode)
End function

function KeyHandler_KeyReleased(oEvent) as boolean
    KeyHandler_KeyReleased = False 'cancel KeyReleased
end function

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2756
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Post by JeJe »

Having said that... you'll need this keyHandler for every document you want this... so you're probably better with a shortcut that's available.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Tabyria
Posts: 2
Joined: Fri Feb 23, 2018 3:04 pm

Re: Override shortcuts in Writer

Post by Tabyria »

Ah, thanks JeJe. Keyhandler might help someone else but that looks pretty complex to me. And you're right, if I need to do that for every doc I'm better off using another shortcut. Annoying as these are the shortcuts I've used for years and changing them will considerably slow my typing down while I relearn all of them. Oh well.
Apache OpenOffice 4.1.5 on Windows 10
JeJe
Volunteer
Posts: 2756
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Post by JeJe »

It might be an operating system thing, not an OpenOffice thing... what happens in other programs like Notepad when you type Ctrl+Alt+a - does it produce á there as well. If so maybe you need to look at your Window's Keyboard language settings.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
FJCC
Moderator
Posts: 9231
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Override shortcuts in Writer

Post by FJCC »

You can consider using the extension Compose Special Characters. It uses pairs of characters followed by a particular key combination to insert special characters. I set my key combination to ALT + Z, so if I type e` followed by ALT + Z I get è.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
JeJe
Volunteer
Posts: 2756
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Post by JeJe »

I can change the Alt+Shift+E shortcut okay and I have Windows 8.1 and OO 4.1.2
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply