Help with a script

Hello,

I’m a newbie in Applescript, i did a script for an artistic performance, the idea is to create “glitches” in picture adding text to the source code of the picture file.

My problem is when I execute the script, after clicking ok to the dialog box in wich I can see the part of text choosed to “glitch” the picture, I have to click on the finder icone in the dock to continue the script (display my “glitched” picture with preview)

Somebody can help me?

Thx

Damien

here is the script :

set MyImage to choose file --choisir un fichier d'image
set MyText to "/Users/damienpetitot/Documents/DATA_ME/textdam.txt" --choisir un fichier texte

set n to random number from 1 to 15
set m to random number from 2 to 150
tell application "TextEdit"
	open MyText
	tell document 1
		set Myline to paragraph n
		close
		open MyImage
		activate front window
		set paragraph m to Myline
		get Myline
		save
		close
	end tell
end tell
tell application "Finder" -- cette partie me sert à positionner mes fenêtre où je veux
	activate
	set c to (count windows)
	ignoring application responses
		display dialog Myline
	end ignoring
end tell
tell application "System Events"
	tell application process "Finder"
		repeat until ((count windows) > c)
			delay 0.5
		end repeat
		set position of window 1 to {1000, 22}
	end tell
end tell
tell application "Finder"
	activate
	open MyImage using application file "preview.app" of folder "Applications" of startup disk
	tell application process "Preview"
		set position of window 1 to {20, 22}
	end tell	
end tell