Clipboard plain text

Sorry, Having trouble narrowing my search in the forums…

If I have “&T” in the middle of my text body in Pages with the font set to copperplate, the following applescript inserts text as helvetica.

So, how do I set the text on the clipboard with no attributes so the paste adopts the attributes in the paragraph in Pages (ie. font/bold/italic/size etc.)?
Preferably without scripting another application (TextEdit etc.)

  • ( confused why ANY text attributes get loaded on the clipboard from a script)
(*
SET UP PAGES WITH "&T" IN THE BODY
SET "&T" TO BOLD AND/OR SOME OTHER FONT BESIDES HELVETICA
*)

set the clipboard to "some text on the clipboard" as text

tell application "Pages"
	activate
	tell application "System Events" to (keystroke "f" using {command down})
	tell application "System Events" to (keystroke "&T")
	tell application "System Events" to (keystroke return)
delay .3
	tell application "System Events" to (keystroke "v" using {command down})
end tell 

Browser: Safari 419.3
Operating System: Mac OS X (10.5)

The simple answer, In keeping with your applescript, would be to use the 'Paste and Match Style" menu.

(*
SET UP PAGES WITH "&T" IN THE BODY
SET "&T" TO BOLD AND/OR SOME OTHER FONT BESIDES HELVETICA
*)
set the clipboard to "some text on the clipboard" as text

tell application "Pages"
	activate
end tell
tell application "System Events"
	
	tell application process "Pages"
		
		keystroke "f" using {command down}
		keystroke "&T" & return
		delay 0.3
		tell application "System Events" to keystroke (key code 53) --escape the find widow, to make way for the paste
		delay 0.3
		keystroke "V" using {option down, shift down, command down}
	end tell
end tell

Thanks. That gets it done! It’s a utility script so it doesn’t have to be pretty or lightening fast.

I think the apple should provide “find” in the dictionaries of apple apps so as to avoid the “find” dialog box. It’s pretty basic and universal - perfect for the dictionaries.

There is one in Pages :wink:

set findString to "&T"

tell application "Pages"
	tell document 1
		set o to offset of findString in body text as text
	end tell
end tell
if o = 0 then say "not found"