0

请原谅我不够优雅的脚本编写能力,但是在脚本编辑器本身中调用该脚本时运行良好。但是,当我将其另存为应用程序时,该图标并未显示它是液滴并且无法正常工作。任何帮助是极大的赞赏!

try
    set destinationFolder to "Mercury:F1_PropertyLogos:"
    tell application "Finder" to set logoFileName to name of item 1 of (get selection)

end try

set file_name to logoFileName
set file_name to remove_extension(file_name)


on remove_extension(this_name)
    if this_name contains "." then
            set this_name to ¬
                    (the reverse of every character of this_name) as string
            set x to the offset of "." in this_name
            set this_name to (text (x + 1) thru -1 of this_name)
            set this_name to (the reverse of every character of this_name) as string
    end if
    return this_name
end remove_extension

tell application "Finder"
    set selected_items to selection
    set theFolder to "Mercury:F1_PropertyLogos:"

    repeat with x in selected_items
            move x to theFolder
    end repeat
end tell

tell application "QuarkXPress"
    set mypath to "Mercury:F1_Layouts:"
    set myfile to file_name
    set extension to ".qxp"
    set logoFolderPath to "Mercury:F1_PropertyLogos:"
    set myLogoFile to file_name
    set myLogoExtension to ".psd"
    set myLogo to (logoFolderPath & myLogoFile & myLogoExtension)
    open file (mypath & myfile & extension)
    set selected of picture box "Logo" of spread 1 of document 1 to true
    set image 1 of picture box "Logo" of spread 1 of document 1 to file myLogo
    set bounds of image 1 of picture box "Logo" of spread 1 of document 1 to proportional fit
end tell

end
4

1 回答 1

0

要处理拖放到应用程序上的项目,您将需要添加一个打开的处理程序来接收已删除项目的列表(即使只有一个),例如:

on open theDroppedItems
    -- whatever
end open

您可能应该重新排列您的代码,将您的主要语句放入一个可以从多个位置调用的处理程序(或多个处理程序)中,因为双击应用程序将改为调用运行处理程序。

于 2012-08-11T15:53:56.740 回答