在取景器窗口中显示内容

时间:2013-04-11 15:20:56

标签: window applescript show finder

好的,我正在尝试制作一个您输入内容的脚本,然后会出现一个新的查找窗口,其中包含您输入的内容。与聚光灯搜索类似,但在脚本中。

set theFind to text returned of (display dialog "What do you want to find?" default answer "" buttons {"Cancel", "Ok"} default button 2)
    tell application "Finder"
        reveal theFind
    end tell

1 个答案:

答案 0 :(得分:3)

有一个AppKit方法可以完全满足您的要求:-[NSWorkspace showSearchResultsForQueryString:],这意味着您可以使用AppleScriptObjC来使用它。因此,在AppleScript编辑器中,文件>模板新增> Cocoa-AppleScript Applet,然后:

property NSWorkspace : class "NSWorkspace"
NSWorkspace's sharedWorkspace()'s showSearchResultsForQueryString_(theFind)

或者,您可以跳过AppleScriptObjC并使用该方法使用的隐藏Finder命令:

tell application "Finder" to «event aevtspot» theFind
相关问题