首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Applescript:无法将脚本转换为droplet

Applescript:无法将脚本转换为droplet
EN

Stack Overflow用户
提问于 2012-08-11 23:28:00
回答 1查看 195关注 0票数 0

请原谅我不太优雅的脚本编写能力,但是在脚本编辑器中调用脚本时,脚本工作得很好。然而,当我将它另存为应用程序时,图标并没有显示它是一个水滴,因此不能正常工作。任何帮助都是非常感谢的!

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2012-08-11 23:53:57

要处理拖放到应用程序上的项目,您需要添加一个open处理程序,该处理程序接收被拖放的项目的列表(即使只有一个),例如:

代码语言:javascript
复制
on open theDroppedItems
    -- whatever
end open

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11915910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档