This is a guide to using the new extension snippets.
This post has been Updated on 3 May 2022 for PopClip 2022.5.
Once of the actions a PopClip extension can do is press a key combination for us.
As an example, I’m going to make a PopClip extension to create a new TextExpander Snippet (not to be confused with a PopClip extension snippet ). (Long-time PopClip users may know there used to be a TextExpander extension, but it no longer works.)
I checked the TextExpander prefs and saw that it has a global keyboard shortcut for creating a snippet from the current clipboard. This is great, because we can make use of this for our PopClip extension.
First of all we need to go into the Hotkeys section of TextExpander preferences and set a keyboard shortcut for “Create Snippet from Clipboard”:
This can be any key combination of your choice, but here I’m using ⌃E (control and E).
Having done this, we can now make our PopClip extension. I’ve typed out an extension snippet as follows — all you need to do is go ahead and select it:
# popclip
name: TextExpander
icon: circle filled te
before: copy # important line! see "the details" below
key combo: control E
If you’ve chosen a different keyboard shortcut to ⌃E, you’ll need to type out the extension snippet yourself somewhere and alter it. Otherwise, after selecting the text block above with PopClip, you’ll see “Install Extension”.
Now you have an extension that creates a new TextExpander snippet from the selection!
Hopefully you now have an idea how to adapt this for other situations where you can accomplish a task using a keyboard shortcut. Feel free to ask for help in the thread down below, or share things you have made.
The details
Let’s look at the lines of the extension snippet in detail:
-
# popclip
- this has to go at the top of every extension snippet so PopClip knows what it is. -
name
- the name you give the extension. You can choose any name you like. -
icon
- an icon for the extension’s action. Here I have specified a filled circle with the letterste
but you can change that (see here for info) -
before
- this is important for the TextExpander extension. Thebefore
field specifies an action PopClip should perform before the main action. Here I have putcopy
which makes PopClip copy the selection to the clipboard, where TextExpander will find it. -
key combo
- the main action, which is to press a key combination. The key combo is specified ascommand E
- see Specifying key combinations below.
Specifying key combos
The key combo
is simply a sequence of words from command
(⌘), option
(⌥), shift
(⇧) and control
(⌃), followed by the character, name or key code of the key to press.
To specify more than one modifier, just list them separated with spaces, with the key to press at the end. The order does not matter. For example:
key combo: command shift =
key combo: option shift command W
key combo: control command space
PopClip recognises the following named keys: return
, space
, delete
, escape
, left
, right
, down
, up
, and the F keys: f1
to f19
.
Other more ‘esoteric’ keys can also be specified as a virtual key code in hexadecimal format.
Example:
#popclip example to press ⌘Tab
name: Copy, Switch App and Paste
icon: symbol:bolt.circle
before: copy
key combo: command tab
after: paste
Pressing a sequence of key combos
New in PopClip 2022.5, you can press a sequence of keys. This is done by specifying an array of key combos in key combos
(with an ‘s’) field. Example:
#popclip snippet to press ⌘C twice
name: DeepL Translate
title: DeepL
key combos:
- command C
- command C
PopClip will pause for 1/10th of a second after pressing each key combo.
The full details about making extensions are in the technical documentation.