2012-08-11 60 views
0

請原諒我的不那麼優雅的腳本的能力,但是當腳本編輯器內調用腳本工作正常。但是,當我將它保存爲應用程序時,該圖標並未顯示它是液滴,並且不能正常工作。任何幫助是極大的讚賞!的AppleScript:無法向腳本到液滴

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 

回答

0

爲了應對物品掉落到應用,你將需要添加一個開放處理接收的掉落的物品清單(哪怕只有一個),例如:

on open theDroppedItems 
    -- whatever 
end open 

您應該重新排列代碼以將主語句放入可從多個地方調用的處理程序(或處理程序),因爲雙擊該應用程序將調用運行運行程序。

+0

其實,我只是想通了,額外的「結束」在我的腳本結束時阻止其正確創建的液滴。謝謝! – user1592401 2012-08-11 18:16:27

+1

在這種情況下,必須一直在談論的「小程序」 - 您的應用程序不會是能夠處理的物品拖放到它沒有一個開放的句柄(這使它成爲一個「滴」)。 – 2012-08-11 18:33:12