this droplet works without xcode but doesnt work inside it…
on open listOfDocs
set numDocs to count of listOfDocs
set currentDoc to 1
repeat with theDoc in listOfDocs
set fileInfo to name extension of (info for theDoc)
display dialog "File " & currentDoc & " of " & numDocs & " is a " & fileInfo & ": " & name of (info for theDoc) buttons {"Print", "Stop Printing", "Skip This One"} default button 1 giving up after 3
try
if fileInfo = "doc" then
tell application "Microsoft Word"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
else if fileInfo = "sql" then
tell application "TextEdit"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
end if
on error
display dialog �
"either that item wasnt printable, you are not conected to the printer, you dumb or i hate you... so fix one of those things!" buttons {"I will try to be smarter next time"} default button 1 with icon 2
end try
set currentDoc to (currentDoc + 1)
end repeat
end open
i checked on action drop
and it does nothing absolutly nothing…
and this doesnt work
on drop theObject drag info listOfDocs
set numDocs to count of listOfDocs
set currentDoc to 1
repeat with theDoc in listOfDocs
set fileInfo to name extension of (info for theDoc)
display dialog "File " & currentDoc & " of " & numDocs & " is a " & fileInfo & ": " & name of (info for theDoc) buttons {"Print", "Stop Printing", "Skip This One"} default button 1 giving up after 3
try
if fileInfo = "doc" then
tell application "Microsoft Word"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
else if fileInfo = "sql" then
tell application "TextEdit"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
end if
on error
display dialog ¬
"either that item wasnt printable, you are not conected to the printer, you dumb or i hate you... so fix one of those things!" buttons {"I will try to be smarter next time"} default button 1 with icon 2
end try
set currentDoc to (currentDoc + 1)
end repeat
end drop
or this
on drop theObject drag info listOfDocs
set numDocs to count of listOfDocs
set currentDoc to 1
repeat with theDoc in listOfDocs
set fileInfo to name extension of (info for theDoc)
display dialog "File " & currentDoc & " of " & numDocs & " is a " & fileInfo & ": " & name of (info for theDoc) buttons {"Print", "Stop Printing", "Skip This One"} default button 1 giving up after 3
try
if fileInfo = "doc" then
tell application "Microsoft Word"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
else if fileInfo = "sql" then
tell application "TextEdit"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
end if
on error
display dialog ¬
"either that item wasnt printable, you are not conected to the printer, you dumb or i hate you... so fix one of those things!" buttons {"I will try to be smarter next time"} default button 1 with icon 2
end try
set currentDoc to (currentDoc + 1)
end repeat
end drop
Actually, you had the right script to begin with, using the “on open” handler just like regular AppleScript does. Generally, for a droplet, you can just use the same code in your AppleScript Studio droplet that you used in your regular AppleScript droplet. The one exception to this, as I mentioned before, is to add the “return true” line right at the end of it, to workaround that bug in ASS’s “on open” handler.
But before you get to the AppleScript itself, first you need to open the “MainMenu.nib” file in Interface Builder and connect an “open” event handler to the “File’s Owner” instance in the .nib file. Use this image as a guide. Select the “File’s Owner” (which represents your application itself, in a sense) then click the “open” event handler under the Application section, then choose the AppleScript that will handle that event (it should show your default applescript in the bottom section of the Inspector window in IB). Click “Edit Script” and paste the following script into it:
on open listOfDocs
set numDocs to count of listOfDocs
set currentDoc to 1
repeat with theDoc in listOfDocs
set fileInfo to name extension of (info for theDoc)
display dialog "File " & currentDoc & " of " & numDocs & " is a? " & fileInfo & ": " & name of (info for theDoc) buttons {"Print", "Stop Printing", "Skip This One"} default button 1 giving up after 3
try
if fileInfo = "doc" then
tell application "Microsoft Word"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
else if fileInfo = "sql" then
tell application "TextEdit"
activate
open theDoc as alias
print theDoc as alias
quit
end tell
delay (0.4 * minutes)
end if
on error
display dialog "either that item wasnt printable, you are not conected to the printer, you dumb or i hate you... so fix one of those things!" buttons {"I will try to be smarter next time"} default button 1 with icon 2
end try
set currentDoc to (currentDoc + 1)
end repeat
return true -- <--- this is a key step to prevent the crash of your droplet at the very end
end open
Again, this script is basically your original plus the “return true” line.
Then, you’re all set.
Hope this helps…
P.S.
Oh, the “on drop” handler is meant for when you drop files onto an object in a window of the application or something, rather than on the icon of the application itself (at least I think that’s how it works, I haven’t quite got to that yet)…