Applescript Error cannot make to unicode text

偶尔善良 提交于 2019-12-06 13:14:19

It seems that text from your application is copied as a RTF stream. To convert it to a simple text please try using as text:

(the clipboard as text)

Update

After reading your question again, I I've downloaded WriteRoom and came up with this solution:

tell application "WriteRoom" to activate
tell application "System Events"
    tell application process "WriteRoom"
        set content to (value of text area 1 of scroll area 1 of front window) as text
    end tell
end tell

display dialog content

Then you can use the content variable for further processing. Use the Mac program Accessibility Inspector to find out the UI definition of any window as I did.

It's an old question and I see you got the fix. But seeing that I get the same "An error of type -25130 has occurred. Number -25130" with an Applescript (not using WriteRoom, using Sigil) I find out another fix in these cases.

Often it's really very important to add a small delay using GUI scripting. And actually even with some pre-selected text and just having a single keystroke I got that error. Not so if delay 0.1 before and after keystroke (or you have to play with different delay 0.2 and so on).

delay 0.1
tell application "System Events" to keystroke "c" using command down
delay 0.1
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!