-1

https://github.com/pilotmoon/PopClip-Extensions#types-of-actions

我注意到popclip扩展可以直接调用macos服务菜单。(可在系统偏好设置 -> 键盘 -> 键盘快捷键 -> 服务中找到)

那么,是否可以通过其他方式或脚本调用呢?因为我想在 alfred 工作流程中调用它们。

4

1 回答 1

0
#!/usr/bin/osascript -l JavaScript
ObjC.import('Cocoa')
ObjC.import('stdlib');

function run(argv) {
    let service = $.getenv('service');  //variable set via args utility
    let text = $.getenv('input');       //variable set via args utility

    $.NSPasteboard.generalPasteboard.clearContents;
    $.NSPasteboard.generalPasteboard.writeObjects([text]);

    console.log("performing service %s", service)
    console.log("performing on text %s", $.NSPasteboard.generalPasteboard.pasteboardItems[0])

    let ret = $.NSPerformService(service, $.NSPasteboard.generalPasteboard)
    if (!ret) return `Service “${service}” failed`
}
于 2022-02-24T09:03:58.627 回答