I have been working on a script that uses the clipboard into mail. Using some of the examples from this form i got it to work only partially. I need help with the keystroke "v"as i am loosing the focus on the body of mail and it will not paste my picture. It does work if i put my cursor in the body of my outgoing mail and use command “v” manually. The script works fine if the clipboard has text. If someone could please direct me in the right direction. Also do i have the error checking correct.
Thanks,
Polishprince
--A Script to take clipboard to Mail regardless of content or class
--Check to see if contents of clipboard is text or graphics
set thisFile to "Important Data for you"
set cbContent to (the clipboard)
set cbClass to class of (the clipboard)
try
if cbContent is not {} then
if ((cbClass is picture) or ((cbClass is record))) then
--display dialog "Its an image" --Used only for syntax checking
tell application "Mail"
activate
make new outgoing message at end of outgoing messages with properties {content:thisFile, subject:"Data you requested", visible:true}
tell application "System Events"
tell (application process 1 whose frontmost is true)
keystroke "v" using command down
end tell
end tell
end tell
else
--It is not a picture so cbContent will be pasted in as text
tell application "Mail"
--display dialog ((cbClass as string) & " (" & cbContent & ")") as string --Used only for syntax checking
make new outgoing message at end of outgoing messages with properties {content:cbContent, subject:"Data you requested", visible:true}
end tell
end if
end if
on error
set cbContent to {}
display dialog "An error has occured"
end try
Model: Mac G5 dual 250
AppleScript: version 2.2
Browser: Safari 523.10
Operating System: Mac OS X (10.5)