Scriptable application with commands in r/o

Many properties is r/o (read only) for a scriptable application. Don’t ask me why its like that
but most of whose settings could be set with GUI Scripting.

To demonstrate I made a script that make a new document with template “Blank” there document body is false (page layout). The script could be a beginning to a template for Menu Script.


on run
	-- Make a new document with the template "Blank"
	tell application "Pages"
		make new document with properties {document template:template "Blank"}
	end tell
	
	-- Make sure we are in document in the toolbar
	tell application "System Events" to tell process "Pages"
		set frontmost to true
		tell window 1
			tell toolbar 1 to tell group 6
				tell radio button "Document" to click
			end tell
		end tell
	end tell
	
	tell application "System Events" to tell process "Pages"
		set frontmost to true
		tell window 1
			tell splitter group 1 to tell scroll area 2
				tell checkbox 3
					click
				end tell
			end tell
			
			-- Click the button "Convert" in the sheet.
			tell sheet 1
				tell button "Convert" to click
			end tell
		end tell
	end tell
end run

This is freaking me out. It’s the second time I’ve seen this in the last couple days.

This script should not work.

tell application x to y

should not start a tell block.

This is what’s used to send a single command to an application, and all the subsequent commands should not be compiling or sent to the app. (System Events, in this case).

In the other example the appleScripter was saying it was failing intermittently. I’m wondering why it doesn’t fail 100% of the time.

If I understand you correctly or maybe you have never done GUI Scripting.

If you take a look in script terminology for System Events and the class Ui element
you could find element of toolbar, radio button, menu item…
To be able to script UI you need to use application “System Events” the second tell block
tell’s the process… In other words if you ask for every process to return a menu item
you will get every application running… and properly not very useful.

My first post was about scripting a r/o (read only) property. In others words you couldn’t
do ‘set document body to false’ in tell block of Pages. The reason is its r/o read only.

I’ve done plenty of GUI scripting. More than I would like to, but sometimes it’s a last resort.

I see my mistake now.

Carry on.