运行命令不起作用? AppleScript的

时间:2016-03-22 18:41:22

标签: performance applescript

我原来有这些代码

set Chrome_List to {"Open Chrome", "Open Google Chrome", "Open GoogleChrome", "Open browser", "Open chrome"} --List of words, meaning "Good"

set TextEdit_List to {"Open Textedit", "Open Text Edit", "open text", "open empty text

"} --List of words, meaning "Bad"

set Gmail_List to {"Open Gmail", "Open Email", "open mail", "open Google Mail

", "open G-Mail"}

set photobooth_list to {"Open Photo Booth", "Open PhotoBooth", "open camera", "open Camera

", "open photo booth"}
set complete_list to Chrome_List & TextEdit_List & Gmail_List & photobooth_list

tell application "SpeechRecognitionServer"
	
	set theResponse to listen for complete_list with prompt "Which Application should I open"
	
	if (Chrome_List contains theResponse) then
		
		run script "/Volumes/Genesis/Application/GoogleChrome/GoogleChrome.scpt"
		
	else if (TextEdit_List contains theResponse) then
		
		run "/Volumes/Genesis/Application/TextEdit/TextEdit.scpt"
		
	else if (Gmail_List contains theResponse) then
		
		run "/Volumes/Genesis/Application/Gmail/Gmail.scpt"
	else if (photobooth_list contains theResponse) then
		
		run "/Volumes/Genesis/Application/PhotoBooth/PhotoBooth.scpt"
		
	end if
end tell
end

该代码链接到此代码:

say "Opening Photo Booth"
launch application "Photo Booth"
end
end
end

但出于某种原因,当我告诉它“打开PhotoBooth”时,它说:“/ Volume /Genesis/Application/PhotoBooth/PhotoBooth.scpt”不理解“运行”消息。

Gmail也是如此,但GoogleChrome和TextEdit等其他应用都可以正常使用。

有没有人对此有解决方法?

2 个答案:

答案 0 :(得分:0)

尝试将脚本保存为应用而不是编译脚本。 Gmail.app与Gmail.scpt

此外,将命令从“运行”更改为“打开”。

do shell script "open '/Volumes/Genesis/Application/PhotoBooth/PhotoBooth.app'"

答案 1 :(得分:0)

你有一个错字。在第一次出现时你有:

run script "…

但是其中一些你只是

run "…

您需要运行脚本。另外,在你的第二个脚本中,我建议

tell application "Photo Booth" to activate

而不是使用忽略on open事件调用的launch(除非你确定这是你想要的)。

相关问题