I need to click the Page Thumbnails pane (which is shown at the left side on the screenshot below) in a Pages document and then select all the pages there, …
and there is a problem in the first step. When I click the Page Thumbnails manually and record this action with Automator, it looks as follows:
click list 1 of scroll area 1 of splitter group 1 of window "test-document" of application process "Pages"
But when I try the same line in AppleScript, it doesn’t seem to work. Why?
activate application "Pages"
tell application "System Events"
click list 1 of scroll area 1 of splitter group 1 of window "test-document" of application process "Pages"
keystroke "a" using command down
end tell
What you seem to be referring to looks like a menu to me.
Try “menu 8 of menu 1 of window 1” or something close to that. Of course, maybe things have changed.
What you seem to be referring to looks like a menu to me.
No, I don’t mean a menu. I talk about the area on the left.
Edit: Note the document is in Page Layout mode (File > Convert to Page Layout)
Sorry, I was distracted by the red box in the menu.
I’m not sure about the zone on the left as my version of pages is prehistoric. But, perhaps it’s because there’s an issue using ‘click’ on a ‘list’. Assuming that the element chain is correct up to that point, try getting ui elements of …
your list. Perhaps the result will reveal another item that you can click on.
I should add that there is also a select
command for ui scripting. Dunno if it will produce different results here but it might be more useful than a click in this case.
“Select All” doesn’t seem to be available for the Thumbnails area.
Did you notice it is disabled in the menu?
So 'keystroke “A” ’ would do nothing
It is available if the document has been converted to Page Layout.
1 Like
Yes, exactly. Sorry that I forgot to mention that the document is in Page Layout mode.
Try this:
activate application "Pages"
tell application "System Events"
tell process "Pages"
set focused of list 1 of scroll area 1 of splitter group 1 of window "Untitled" to true
keystroke "a" using command down
end tell
end tell
They don’t make it easy…
As previously mentioned, this will only work if the Pages document is in Page Layout mode. Above script uses Pages 13.1.
1 Like
Yep, this works, thank you so much. Of course, it was necessary to change “Untitled” to the name of the opened document.
(After three days with real-life AppleScript, that is, trying to solve real tasks from my workflow, which aren’t really complicated themselves, I can say that the language is not as easy as I expected before, when looked at its syntax!)
Out of curiosity, and to improve my understanding of AppleScript, is the line
keystroke "a" using command down
really belongs to the tell process "Pages"
part? In other words, would it be more correct to modify the existing version as follows:
activate application "Pages"
tell application "System Events"
tell process "Pages"
set focused of list 1 of scroll area 1 of splitter group 1 of window "pages copy" to true
end tell
keystroke "a" using command down
end tell