2017-01-16 22 views
0

我怎麼能作出這樣的插入表情符號到聚焦的文本字段一個AppleScript?插入表情符成焦點的文本輸入

我試圖

tell application "System Events" to keystroke "" & return 

但這放入"aa",而不是我想要的表情符號。

回答

1

你不能做到這一點與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 
+0

但我不知道是什麼應用程序,我需要將其發送給,我只是想將它發送到inpu – theonlygusti

+0

當前最前面/集中文本,然後你可以把字符放在剪貼板上併發送按鍵⌘V。 – vadian

+0

有沒有辦法重設剪貼板?因爲,幾乎看起來像一個完美的解決方案 – theonlygusti