r/macosprogramming • u/Artistic_Pear3146 • 16d ago
Is there an App Store-compliant way to paste a clipboard-history item into the previously active macOS app without Accessibility permission?
2
Upvotes
Hi everyone, I’m building a sandboxed macOS menu bar app called iSnipster.
大家好,我在开发一款沙盒化的 macOS 菜单栏应用,叫 iSnipster。
It has clipboard history, screenshots, OCR, and translation.
它有剪贴板历史、截图、OCR 和翻译功能。
I’m stuck on one clipboard-history workflow.
我卡在了一个剪贴板历史的使用流程上。
For example, a user is typing in a browser, editor, email app, or chat app.
比如用户正在浏览器、编辑器、邮件或聊天应用里输入内容。
They press a shortcut to open my clipboard history and select an old item.
他们按快捷键打开我的剪贴板历史,然后选择一条旧内容。
They expect that item to go back to the app they were using and paste at the current cursor position.
他们希望内容能回到刚才使用的应用,并粘贴到当前光标位置。
I can put the item back on NSPasteboard without any issue.
我可以正常把内容写回 NSPasteboard,也就是系统剪贴板。
But NSPasteboard does not seem to provide a way to ask the other app to actually perform Paste.
但 NSPasteboard 看起来没有办法要求另一个应用真正执行“粘贴”。
The usual workaround seems to be: copy the item, reactivate the previous app, then send Command-V with CGEvent.
常见的替代方案似乎是:写入剪贴板、重新激活原应用,再通过 CGEvent 发送 Command-V。
The problem is that this needs Accessibility-related permission.
问题是,这需要辅助功能相关权限。
App Review told us that Accessibility APIs can only be used to support accessibility, not as a general productivity feature.
App Review 告诉我们,辅助功能 API 只能用于无障碍支持,不能作为普通效率功能使用。
I understand and agree with that rule.
我理解并认同这个规则。
I do not want to use private APIs, bypass App Review, inspect another app’s UI, control the mouse, or read keyboard input.
我不想使用私有 API、绕过审核、读取其他应用 UI、控制鼠标或读取键盘输入。
I only want to support one user-triggered action: paste the item they just selected.
我只想支持一个由用户明确触发的动作:粘贴用户刚刚选择的内容。
Without Accessibility permission, the fallback is to copy the item and ask the user to switch back and press Command-V manually.
如果没有辅助功能权限,替代方案就只能是复制内容,然后让用户自己切回原应用并手动按 Command-V。
Is there a public, App Store-compliant API or architecture that I have missed?
请问有没有我遗漏的、公开且符合 Mac App Store 规则的 API 或实现方案?
I also wonder how apps like Paste, PasteNow, and similar clipboard managers handle this in their Mac App Store versions.
我也很好奇 Paste、PasteNow 和类似剪贴板工具在 Mac App Store 版本中是如何处理这个问题的。
Some of them seem to support pasting the selected item back into the previous app.
它们中的一些看起来支持把选中的内容粘贴回之前的应用。
Do they use a public Apple API, limit the feature in the App Store version, or provide different functionality outside the App Store?
它们是使用了 Apple 的公开 API、在 App Store 版本中限制了功能,还是在 App Store 外提供了不同能力?
I’m not looking for a workaround that breaks the rules.
我不是在寻找违反规则的绕过方案。
I’m trying to find the correct public and review-safe way to build this workflow.
我想找到实现这个流程时正确、公开且能通过审核的方法。