Copy and Paste and Compare then Stop

Hi,

Just getting into Applescripting and need a little help.

I am trying to write a simple script that copies from one filed and past to another then moves on to the next clip and repeats. I am trying to get it to repeat until it reaches the end where it would in a sense copy the same thing twice.

I am trying to have it cycle twice then compare the clipboard if it is the same thing then stop. For some reason I can’t get it to work properly.

Any thoughts would be great. Thanks a ton.


set textCopy to 1
try
	tell application "" to activate
	delay 0.5
	tell application "System Events" to tell process ""
		repeat
			keystroke "c" using {command down}
			set selecTxt to the clipboard as text
			keystroke tab
			keystroke tab
			keystroke "v" using {command down}
			keystroke return
			key code (124) using {command down, control down}
			delay 0.1
			keystroke tab
			keystroke "c" using {command down}
			set selecTxt to the clipboard as text
			if (the clipboard) is equal to selecTxt then
				set textCopy to textCopy - 1
				if textCopy is equal to 0 then
					return
				end if
			else
				keystroke tab
				keystroke tab
				keystroke "v" using {command down}
				keystroke return
				key code (124) using {command down, control down}
				delay 0.1
				keystroke tab
			end if
		end repeat
	end tell
end try