如何制作将表情符号插入焦点文本字段的苹果脚本?
我试过了
tell application "System Events" to keystroke "🐶" & return
但这"aa"
而不是我想要的表情符号。
你不能
用keystroke
这样做。
或者,将相应 UI 元素的属性AXSelectedText
的值设置为字符,例如
activate application "TheApp"
tell application "System Events"
tell process "TheApp"
set value of attribute "AXSelectedText" of text field 1 of window 1 to "🐶"
keystroke return
end tell
end tell
您可以使用 UIElementInspector 或 UI 浏览器确定对 UI 元素的引用。
或使用剪贴板:
set the clipboard to "🐶"
tell application "System Events"
keystroke "v" using command down
keystroke return
end tell