Override shortcuts in Writer

Creating a macro - Writing a Script - Using the API

Override shortcuts in Writer

Postby Tabyria » Fri Feb 23, 2018 3:15 pm

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
Tabyria
 
Posts: 2
Joined: Fri Feb 23, 2018 3:04 pm

Re: Override shortcuts in Writer

Postby JeJe » Fri Feb 23, 2018 5:07 pm

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. )
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 218
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Postby JeJe » Fri Feb 23, 2018 5:17 pm

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
https://forum.openoffice.org/en/forum/v ... 45&t=33914

Code: Select all   Expand viewCollapse view

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

Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 218
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Postby JeJe » Fri Feb 23, 2018 5:20 pm

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.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 218
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Postby Tabyria » Fri Feb 23, 2018 5:38 pm

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
Tabyria
 
Posts: 2
Joined: Fri Feb 23, 2018 3:04 pm

Re: Override shortcuts in Writer

Postby JeJe » Fri Feb 23, 2018 5:53 pm

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.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 218
Joined: Wed Mar 09, 2016 2:40 pm

Re: Override shortcuts in Writer

Postby FJCC » Fri Feb 23, 2018 6:09 pm

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 è.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6505
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Override shortcuts in Writer

Postby JeJe » Fri Feb 23, 2018 6:16 pm

I can change the Alt+Shift+E shortcut okay and I have Windows 8.1 and OO 4.1.2
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 218
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: JeJe, RPG and 5 guests