Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从注释记号中提取PresentationNotes_Javascript_Applescript_Osx Yosemite_Automator_Javascript Automation - Fatal编程技术网

Javascript 从注释记号中提取PresentationNotes

Javascript 从注释记号中提取PresentationNotes,javascript,applescript,osx-yosemite,automator,javascript-automation,Javascript,Applescript,Osx Yosemite,Automator,Javascript Automation,我很难使用JXA(osx的Javascript)从主题演讲中提取presentationNotes,我不想使用applescript。除了提取注释,这个脚本还有更多的功能 这似乎相当简单。然而,当我得到presentationNotes时,它在一个RichText对象中,似乎无论如何都不需要得到普通文本。 所以我想我应该打开textEditor,把它们写出来。 我不知道该怎么做 var app = Application('Keynote') document = app.documents[0

我很难使用JXA(osx的Javascript)从主题演讲中提取presentationNotes,我不想使用applescript。除了提取注释,这个脚本还有更多的功能

这似乎相当简单。然而,当我得到presentationNotes时,它在一个RichText对象中,似乎无论如何都不需要得到普通文本。 所以我想我应该打开textEditor,把它们写出来。 我不知道该怎么做

var app = Application('Keynote')
document = app.documents[0] 
slide_name = document.name()
i = 1 // loop through folder contents
folder_name = 'chapter'+i
//create a folder
var textEdit = Application('textEdit')
textEdit.activate()
var doc = textEdit.make({new:'document'})
doc.text = "fsdfsdfs"
var c = 0;
for(slide in document.slides){

    var s = document.slides[slide]
    var note = s.presentationNotes // returns object specifier

    //textEdit.documents[0].push(note)
    // I've tried lots of things here.


}

任何想法或帮助都将不胜感激。我看过一些applescript的例子,但是我无法翻译它们。显然,applescript as text与toString()无关。

您就快到了。不应推送文本,而应推送文本的段落对象

下面是一个完整的示例(仅限文本)。 它使用当前打开的注释记号和文本编辑文档

var Keynote = Application("Keynote");
var presentation = Keynote.documents[0];

var TextEdit = Application("TextEdit");
var document = TextEdit.documents[0];

document.paragraphs.push( TextEdit.Paragraph({color:"red", size:18}, "presentation: "+ presentation.name()+"\n" ))

for (var i=0; i<presentation.slides.length; i++) {
    slide = presentation.slides[i];
    slideTitle = slide.defaultTitleItem().objectText();
    notes = slide.presenterNotes(); // text only

    document.paragraphs.push( TextEdit.Paragraph({color:"blue", size:14}, "\n"+ (i+1) +": "+ slideTitle + "\n") )   
    document.paragraphs.push( TextEdit.Paragraph({}, notes +"\n") ) 
}
var注释记号=应用程序(“注释记号”);
var presentation=Keynote.documents[0];
var TextEdit=应用程序(“TextEdit”);
var document=TextEdit.documents[0];
document.parations.push(TextEdit.paration({color:“red”,size:18},“presentation:“+presentation.name()+”\n”))

对于(var i=0;i您是如何测试获取文本的?当我执行slide.presenterNotes()时,我会得到一个错误。在shell中运行它并执行console.log(notes)永远不会打印文本我会出错。今晚回家后我会试试。谢谢。如果我有任何问题,我会告诉你。没有测试。我刚才用脚本编辑器检查过,如果幻灯片没有演讲者笔记,它会返回“”。再次感谢。今晚我会给你回复,但我在做演示笔记时非常肯定()它会说不是函数。我会让你知道发生了什么。可能是打字错误?应该是presenterNotes(),而不是presentationNotes()。哇,我羞愧地低下头,哭着睡着了。