Ask Your Question

Using OSX system-level shortcuts (specifically Dictionary look-up)? also, How to use a macro to run a script (to interact with another program)?

asked 2015-08-31 05:53:29 +0200

lostinthesound gravatar image

updated 2015-09-05 13:53:02 +0200


Is there a way to use OSX system-level shortcuts (such as the Dictionary-look up feature) in Writer? I want to be able to highlight a word and have that word pasted into Mac's built-in dictionary application with a single keystroke.

In most applications, I can do this with a shortcut that is assigned globally within the OSX system, but for whatever reason, this doesn't work/ is disabled in LibreOffice (I assume so that it doesn't interfere with LibreOffice's own shortcuts).

I am a translator so being able to look up a word quickly this way would help me alot, and save me from having to copy the text, switch applications, navigate to the dictionary search bar, paste the text, and hit enter every time I need to look up a word.

an alternative solution would be to (bypass the system shortcut method and simply) copy and paste something from LO into another program using a macro, but I have no idea how I might program a macro to do this.

For info on the system level dictionary shortcut in OSX see the following Apple Support Website:

Thanks alot!


edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-08-31 16:58:21 +0200

Alex Kemp gravatar image

updated 2015-09-03 23:11:58 +0200

Hi lostinthesound

Shortcut-keys + a dialog to help you customise them are found:


You will first need to create a macro for the action that you want before what follows below. Part of that is easy ("highlight + copy the word into the Clipboard") but I'm hazy on the external features of the action ("paste into the Dictionary software search bar, search for it, copy the result") (I no longer use a Mac). Nevertheless, I'm going to assume that you have called the script "dictionaryIntegration". See bottom for the beginnings of such a script.

The following is drawn from the Writer help using


  1. (menu):ToolsCustomiseKeyboard
  2. In the Category list box, scroll down and open the "LibreOffice Macros" entry.
  3. Click to get to where you have stored your script.
    (this can easily be the most difficult part!)
    (see below)
  4. Open any scripting language entry to see the available modules + select the "dictionaryIntegration" module.
  5. In the Function list box you will now see a list of all functions in that module. Select the "dictionaryIntegration" function.
  6. Click the option button for LibreOffice or Writer
    (this sets the scope of the action)
    (the options will change according to which applications are currently open).
  7. In the Shortcut Keys list box, select a key combination that you want to use and click Modify
    (that key combo now appears within Keys next to your script)
  8. Click on OK


  • The help says to look in the Category list box, open the LibreOffice Macros entry & look for:-

LibreOffice Macros : LibreOffice installation share directory
(available for all)
My Macros : LibreOffice user directory
(available only for the user)

I do not have any universal macros (that I know about) but also do not have the above sections. Instead, I have:-

user : (containing my user-macros)
share : (macros that I did not add)

  • has a Function list-box; the Help calls it a Commands list-box


  • Scripts are often composed of multiple sub-routines. Top-level functions that make use of the same sub-routines are collected together into 'modules'.


There is a simple workaround, as detailed at this mac forum post:-

  1. Select word
  2. Right-click selected word
  3. (from the context menu) choose Synonyms
  4. (from the sub-menu) choose Thesaurus…
  5. (a pop-up dialog gives options to select):
    image description

Macro Script:

I've written a script that you can use. However, there are lines at the bottom that need to be changed (at this moment it just calls a message-box with the text of the highlighted word(s)). Info on Shell().

dictionaryIntegration.odt (contains just the macros)

Sub dictionaryIntegration()
rem ----------------------------------------------------------------------
rem macro for MacOS use with
rem define variables
dim doc            as object
dim cursor         as object
dim selection      as object
dim selections     as object
dim word_to_lookup as string

dim count%, cr$, lf$, ht$, i%

cr             = chr( 13 )
lf             = chr( 10 )
ht             = chr( 9 )

rem ----------------------------------------------------------------------
'' prog note:  ThisComponent.getCurrentSelection() (or)
''             ThisComponent.CurrentController.getTransferable()
'' prog note:  only one ...
edit flag offensive delete link more


Thank you for your response. Of course, I know how to assign shortcuts for functions within LibreOffice, but what I want to do is access a system-level OSX function, i.e. another piece of software. I couldn't find a way to do that within the normal shortcut-assigning dialog. Perhaps it can be done with macros, but I don't really know how.

lostinthesound gravatar imagelostinthesound ( 2015-09-01 03:52:45 +0200 )edit

Thank you again for your response. Unfortunately it doesn't quite answer my question. I know how do assign macros as keyboard shortcuts, as you described in your post, but as you wrote " I'm hazy on the external features of the action... I'm going to assume that you have found a way to do it." I haven't, and this is the whole point of the question. Perhaps macros are the solution, but I do not know how or if it is possible to write a macro that accesses an external command.

lostinthesound gravatar imagelostinthesound ( 2015-09-02 08:54:24 +0200 )edit

Workaround added. I see from the forum post linked that neither MS-Office nor LO nor OO contain the necessary Mac system-integration code. Feature request?

Alex Kemp gravatar imageAlex Kemp ( 2015-09-02 11:47:35 +0200 )edit

Thanks again for your answer. So, this workaround simply looks up the word in the LO built-thesaurus? Because I'm doingt translation, a thesaurus won't help, but even if I were to download one of the available dictionaries it won't solve my problem, because I have several specialized dictionaries that I need to use the Mac Dictionary app as well as fact two other dictionary apps that I want be able to have access to. So, the "external application" part of the problem is the key.

lostinthesound gravatar imagelostinthesound ( 2015-09-03 05:28:22 +0200 )edit

One possible solution I thought of was somehow having LO run a small command-line like script that accesses those pieces of software? Is that possible? see Googling, I found this as a possibility, but am not quite Macro-savvy enough to know if this will work:

lostinthesound gravatar imagelostinthesound ( 2015-09-03 05:29:15 +0200 )edit

That last combo should do it (well found!). I've looked through my Macros (lots & lots) & I've never used 'Shell'. Typical. Your main issue is going to be the path/command syntax. Either locate the command smack in the middle of your $PATH, or (better) specify the full filename from root (plus, naturally, make sure that that command is accessible by everyone) (chmod 777 filename). I'll checkout Shell & advise further.

Alex Kemp gravatar imageAlex Kemp ( 2015-09-03 13:53:10 +0200 )edit

I'm writing as much of the Macro for you that I can. I'll edit this as soon as is complete (only 6 hours so far).

Blooming heck! 8 hours. I'm badly out of practice. Nevertheless, it works fine (and almost first time, too). Now, if I can, I'll attach an ODT containing the full macro so that you can easily use it and/or add it to your system. I've never done that before, so it may take another 8 hours! (actually, pretty easy). No text, just the macro routines inside.

Alex Kemp gravatar imageAlex Kemp ( 2015-09-03 20:08:56 +0200 )edit

Hey sorry it's taken a while to get back. Holy Cow, thanks a lot. 8 hours? Jeez if someone had asked me to do 8 hours of work for free I would have laughed in their face... thanks so much! I haven't tried it out yet, but I will tomorrow and report back. In the mean time, I will consider this as solved, since I'm pretty sure I can write a script to do the rest of the job.

lostinthesound gravatar imagelostinthesound ( 2015-09-05 13:38:27 +0200 )edit

answered 2015-09-05 06:42:09 +0200

shm_get gravatar image

I've just tried on this mac.. <ctrl><command>-D _do_ pop up a dictionary search here, in writer and in calc

edit flag offensive delete link more


.... I probably should have mentioned this, but actually part of the problem may that I have reassigned the dictionary command to be <cmd>f2. Changing the binding back, yes it does work, but I have actually a second dictionary program I need to access in this way as well, and also, I need it to also show the app window not just the pop-up "tool-tip" display, so Alex's response does it for me. I should also mention that you can do the dictionary look-up with a three-finger tap.

lostinthesound gravatar imagelostinthesound ( 2015-09-05 13:48:50 +0200 )edit

glad to see that you found a solution that works for your need. reading you topic I thought that the 'default-out-of-the-box' thing was broken, thanks for the clarification.

shm_get gravatar imageshm_get ( 2015-09-06 19:38:27 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-08-31 05:52:32 +0200

Seen: 843 times

Last updated: Sep 05 '15