Readonly
contextThe current context.
Readonly
inputThe current selection.
Readonly
modifiersThe state of the modifier keys when the action was invoked in PopClip.
During the execution of the population function, all the modifiers will read as false.
Readonly
optionsThe current values of the options.
Place mixed content on the pasteboard, optionally showing "Copied" notification to the user.
Optional
options: CopyOptionsPlace the given string on the pasteboard, optionally showing "Copied" notification to the user.
The plain text string to copy
Optional
options: CopyOptionsOpen a URL in a browser or other application.
If a target application bundle identifier is specified via the app
option, PopClip will ask that app to open the URL.
If no target app is specified:
Any parameters etc. in the URL must be appropriately percent-encoded. JavaScript provides the encodeURIComponent() function for this. Alternatively you can use the URL class, which is available as a global in PopClip's JavaScript environment.
URL string or a UrlObject representing the URL to open.
Optional
options: { Options.
Optional
activate?: booleanWhether to request that macOS activate the target app. (Default: true
)
Optional
app?: stringBundle identifier of the app to open the URL with. For example "com.google.Chrome"
.
Optional
backgroundWhen opening a web URL in a supported browser, whether to open the URL in a background tab. (Default: false
)
// examples using string URLs
popclip.openUrl("https://xkcd.com"); // open in current/default browser
popclip.openUrl("https://xkcd.com", {app: "com.brave.Browser"}); // open in Brave browser
// example using URL class
const mailUrl=new URL("mailto:support@pilotmoon.com");
mailUrl.searchParams.append("subject", "What's up?");
popclip.openUrl(mailUrl); // the mailto: link will open in the default mail application
Paste mixed pasteboard content.
Optional
options: PasteOptionsIf the target app's Paste command is available, this method places the given string on the pasteboard
and then invokes the target app's Paste comand. If the restore
flag is set in the options, it will
then restore the original pasteboard contents.
If the target app's Paste command is not available, it behaves as copyText instead.
The plain text string to paste
Optional
options: PasteOptions// place "Hello" on the clipboard and invoke Paste
popclip.pasteText("Hello");
// place "Hello", then restore the original pasteboard contents
popclip.pasteText("Hello", {restore: true});
Invokes a command in the target app.
Either cut
, copy
or paste
.
Optional
options: { Options for the command.
Optional
transform?: "none" | "plain"Transformation to apply to the pasteboard contents. (Default: none
)
none
: regular pasteboard operationplain
: strips away everything but plain textSimulate a key press by the user.
The key to press. When this parameter is a string, PopClip will interpret it as in Key Press actions. When this parameter is a number, PopClip will use that exact key code.
Optional
modifiers: numberAn optional bit mask specifiying additional modifier keys, if any.
// press the key combo ⌘B
popclip.pressKey('command B');
// press the key combo ⌥⌘H
popclip.pressKey('option command H');
// press the return key
popclip.pressKey('return');
popclip.pressKey(util.constant.KEY_RETURN); // equivalent
* // press option and the page down key
popclip.pressKey('option 0x79');
popclip.pressKey(0x79, util.constant.MODIFIER_OPTION); // equivalent
Some key code and modifier constants are available in util.constant.
Share items with a named macOS sharing service.
The name of the sharing service to use.
An array of items to share. Each item can be a string, a RichString object, or a UrlObject.
// share a string with the Messages service
popclip.share("com.apple.share.Messages.window", ["Hello, world!"]);
// share a URL with the Safari Reading List service
popclip.share("com.apple.share.System.add-to-safari-reading-list", [{ url: "https://example.com" }]);
// share a an html string with the Notes service
const item = new RichString("Some <b>simple</b> html", { format: html })
popclip.share("com.apple.Notes.SharingExtension", [item]);
The list of available sharing services is determined by the user's system configuration.
If the service name is not recognized, or if the service cannot handle the supplied items, an error is thrown.
Display text to the user.
The text to display.
Optional
options: { Options.
Optional
preview?: booleanApplies to compact
display mode only. If true
, and the app's Paste command is available,
the displayed text will be in a clickable button, which clicked, pastes the full text.
Optional
style?: "compact" | "large"Display style:
compact
(default): Show the text inside PopClip's popup. It will be truncated to 160 characters when shown.large
: Show as "Large Type" in full screen.
This interface describes the methods and properties of the global popclip object.