gpt4 book ai didi

macos - 获取突出显示的文本

转载 作者:行者123 更新时间:2023-12-03 17:40:06 25 4
gpt4 key购买 nike

我正在开发一个应用程序,我需要在应用程序外部获取用户当前突出显示的文本,有什么方法可以做到这一点吗?

我了解到我可以注册为服务,但我不想这样做。

最佳答案

I'm developing an application in which I need to get the current highlighted text of the user outside my application, is there any way to do this?

I've read that I can register as a service but I don't want to do that.

你真的应该这样做。这是正确的方法。

I don't want to force the user to do a copy, I only want him to highlight the text.

(或者她。)

这就是服务的工作原理:选择某些内容(通常是文本),然后调用服务。

… I wan't to be able to get the highlighted text with the press of a shortcut.

你也可以这样做。

您的服务字典应如下所示:

<!--in Info.plist-->
<key>NSServices</key>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>ROT-13</string>
</dict>

<key>NSKeyEquivalent</key>
<dict>
<key>default</key>
<!-- ⌘ is implicit, and an uppercase letter likewise implies shift -->
<!-- Thus, this is ⌘-shift-e -->
<string>E</string>
</dict>

<key>NSRequiredContext</key>
<dict>
<key>NSServiceCategory</key>
<string>public.text</string>
</dict>

<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
</array>


</dict>

关于macos - 获取突出显示的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19061210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com