AppleScript Drag & Drop Help Xcode
Here is my issue. I have a script inside of an Xcode project that is used when a file is dropped onto the selected object. What this script does is get the path information from the file (where its located), (With single or multiple files) and uses it in the script to copy them to a temp folder for use by another script at a later time. The script works, however its SLOW. when an item is dropped it takes about 10 seconds for it to finish doing whatever it needs to do or is doing. The files being dropped are usually PDF's, or EPS's Does anyone know of a better way to maybe speed it up? Thanks for your help and time!
-Nate
--------------------------
Here Is The Script:
on drop theObject drag info dragInfo
set dataTypes to types of pasteboard of dragInfo
set doclist1 to {}
display dialog "What Is The Ad Number Of The Item To Be Spooled?" default answer "Enter Ad Number Here..." buttons {"Cancel", "Enter"} default button 2
set theadNumber to text returned of result
set contents of text field "adnumber" of window "SafeLaunch" to theadNumber
set preferred type of pasteboard of dragInfo to "file names"
set doclist1 to contents of pasteboard of dragInfo
set dropped to doclist1 is not {}
set items_dropped to doclist1 is not {}
return true
end drop
on conclude drop theObject drag info dragInfo
set mycount to (count of every item of doclist1)
tell progress indicator "progressbar" of window "SafeLaunch"
start
end tell
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 10
set contents of text field "statusfield" of window "SafeLaunch" to "Adding Artwork To List..."
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 30
tell progress indicator "progressbar" of window "SafeLaunch"
start
end tell
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 10
set contents of text field "statusfield" of window "SafeLaunch" to "Adding Artwork To List..."
repeat with repeatVar from 1 to (mycount)
set doclist to item repeatVar of doclist1
set item_reference to (doclist as POSIX file) as alias
set doclist to doclist as POSIX file as alias
set pathTospool to "/private/var/tmp/slspooler/"
do shell script "mkdir -p " & pathTospool & theadNumber
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 40
do shell script "chmod 777 " & pathTospool & theadNumber
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 50
try
set tmpMacPathAd to (path to startup disk as string) & "private:var:tmp:slspooler:" & theadNumber & ":"
tell application "Finder"
duplicate file doclist to alias tmpMacPathAd without replacing
end tell
on error errorMsg number errorNum
tell progress indicator "progressbar" of window "SafeLaunch"
stop
end tell
set theSoundERROR to load sound "WARNING"
play theSoundERROR
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 100
tell progress indicator "progressbar" of window "SafeLaunch" to increment by -100
set contents of text field "statusfield" of window "SafeLaunch" to "idle... (However A List Error Occured)"
delete every image of image view "drop" of window "SafeLaunch"
display dialog "Safe Launch Error #: " & errorMsg
end try
end repeat
tell progress indicator "progressbar" of window "SafeLaunch" to increment by 100
set theSound1 to load sound "adaccepted"
play theSound1
delay 1
say "Art Added" using "Bruce"
set contents of text field "statusfield" of window "SafeLaunch" to "One Art Element Waiting..."
set {visible of button "box" of window "SafeLaunch"} to {true}
if mycount is greater than 1 then
set {visible of button "box2" of window "SafeLaunch"} to {true}
set contents of text field "statusfield" of window "SafeLaunch" to "Multiple Art Elements Waiting..."
end if
set enabled of button "spoolbutton" of window "SafeLaunch" to true
tell progress indicator "progressbar" of window "SafeLaunch"
stop
end tell
tell progress indicator "progressbar" of window "SafeLaunch" to increment by -100
set contents of text field "statusfield" of window "SafeLaunch" to "idle..."
delete every image of image view "drop" of window "SafeLaunch"
end conclude drop
PowerMac G5, iBook G4, Intel MacMini, PowerMac G3 B&W, iMac DV, iBook Tangerine Mac OS X (10.4.7)
PowerMac G5, iBook G4, Intel MacMini, PowerMac G3 B&W, iMac DV Blueberry Mac OS X (10.4.6)