copying images between apps

hello, i´m quite a newbie and i spent several nights on this problem. i hope someone can help. This might be a well-known problem, because i did´t find any “strip-the-pics-out-of-TE+” scripts on the Tex-Edit Plus pages, which is full of scripts of any kind…

i´m trying to make a script which
-cuts the pictures out of tex-edit plus files
-pastes them into graphic converter
-saves them as jpeg with the tex-edit filename + index nr + .jpg
(as a test i used a tex-edit file with four different pictures in it)
what it does is:
-it cuts ALL four pictures out of the tex-edit file
-it saves four jpegs to the desktop with correct index nrs.
but

  • they all contain THE SAME picture, which is the first one of the tex-edit file
    how can it be, that he cuts four different pix out of TE+ and pastes/saves four times the same pic into graphic converter? are there different clipboards?? and where are the other three images?
    thanx in advance for any hint on this problem.
tell application "Tex-Edit Plus"
activate
set tt_file to name of document 1
repeat
count every picture of document 1
set n to the result
if n = 0 then
exit repeat
end if
select picture n of document 1
cut
tell application "GraphicConverter"
activate
new image from clipboard
set name of window 1 to tt_file & "_" & n & ".jpg"
set tt_pic to name of window 1
save window 1 in "Harddisk:Desktop Folder:" & tt_pic as JPEG
close window 1
end tell
end repeat
end tell

Hello.

You need to adjust the repeat command just a bit. As it stands at the moment, it does not cycle through each picture box, it simply uses the same value for n each time it repeats. The value of n needs to change each time through the repeat to allow the selection of the next picture box.

Use the “repeat with n from 1 to someNumber” form for the repeat. This tells the repeat to start at 1 and continue until it hits the number provided in the someNumber variable.
I hope this helps.

tell application "Tex-Edit Plus"
activate
set tt_file to name of document 1
-- start at "1" and continue until the script hits the number of pictures in document 1
repeat with n from 1 to (count of every picture of document 1)
if (count of every picture of document 1) = 0 then
exit repeat
end if
--each time through the repeat the value of n increases by +1
--(this should choose a different picture each time)
select picture n of document 1
cut
tell application "GraphicConverter"
activate
new image from clipboard
set name of window 1 to tt_file & "_" & n & ".jpg"
set tt_pic to name of window 1
save window 1 in "Harddisk:Desktop Folder:" & tt_pic as JPEG
close window 1
end tell
end repeat
end tell

I have no idea if this will be helpful or not - I haven’t the time to test it. If the problem is indeed due to ‘private’ clipboards you may try visiting the Finder (‘tell app “Finder” to activate’) in between visits to Tex-Edit Plus and GC. This often forces the information from an application’s clipboard into the System clipboard.

thanks for your quick answer. unfortunately the problem is still the same.
what makes me wonder is the “logical bug” in the whole thing:

1.) he copies pic 1 from TE+ to the clipboard --and–> pastes/saves pic 1 in GC
so far it is logical, but now:

2.) he copies pic 2 from TE+ to the clipboard --and–> pastes/saves pic 1 in GC

3.) he copies pic 3 from TE+ to the clipboard --and–> pastes/saves pic 1 in GC

4.) he copies pic 4 from TE+ to the clipboard --and–> pastes/saves pic 1 in GC

you see? from the second repeat on he copies a NEW picture to the clipboard, but in graphic converter he seems to have still the first one… seems like TE+ and GC have a different clipboard each. can that be?

my other idea was to transfer the data of the image with the command “get the clipboard as picture”

(result: tell current application
the clipboard as picture
→ «data PICT0C380000000000200020001102FF0C00FFFFFFFF00000000000000000020000000200000000…etc.)

now i´m trying to find out how to transfer that data to graphic converter, but thats another story ; )

anyway, thanks a lot. i´ll keep on trying.