Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将一串文本粘贴到打开的任何应用程序中,并且我宁愿不清除粘贴板,以防有重要的东西,而且我宁愿不将每个字符都变成键盘事件。
还有其他方法吗?
您可以尝试使用可访问性:https ://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Accessibility/cocoaAXIntro/cocoaAXintro.html 虽然它可能是矫枉过正。
另一种选择可能是将粘贴板的当前内容复制到局部变量,将其替换为您自己的字符串,执行粘贴,然后将原始值恢复回粘贴板。取决于你想要做什么。
您可以提供一项服务来粘贴所提供的文本。