0

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, ...

enter image description here

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

Edit: Note the document is in Page Layout mode (File > Convert to Page Layout)

1 Answer 1

1

It seems as if only 1 Page Thumbnail can be selected at a time. If you go ahead and manually select 1 page thumbnail then try control + A, nothing happens. Also if you go to the "Edit" menu while one page thumbnail is selected, you will see that the option to "Select All" is grayed out.

If you are interested, I believe this is a more stable way to script the showing of Page Thumbnails

tell application "System Events"
    tell process "Pages"
        set frontmost to true
        repeat until frontmost
            delay 0.1
        end repeat
        click menu item "Page Thumbnails" of menu ¬
            "View" of menu bar item "View" of menu bar 1
    end tell
end tell

Updated Post To Address The Comment From @jsx97

This should work for you but you may need to adjust the delay times

tell application "System Events"
    tell process "Pages"
        set frontmost to true
        repeat until frontmost
            delay 0.1
        end repeat
        click menu item "Convert to Page Layout" of menu ¬
            "File" of menu bar item "File" of menu bar 1
        delay 1
        click button "Convert" of sheet 1 of window 1
        delay 0.1
        click menu item "Page Thumbnails" of menu ¬
            "View" of menu bar item "View" of menu bar 1
        delay 0.1
        set focused of scroll area 1 of splitter group 1 of window 1 to true
        delay 1
        select last list of list 1 of scroll area 1 of splitter group 1 of window 1
            delay 1
        keystroke "a" using {command down}
    end tell
end tell

enter image description here

3
  • Sorry, I forgot to mention that the document is in page layout mode (File > Convert to Page Layout). For such documents there is no problem to manually select thumbnails with Command-A or with menu item Edit > Select All. But I need to automate it. And the first step for this is to "click" this sidebar somehow.
    – jsx97
    Jul 18, 2023 at 17:42
  • @jsx97 I think the edit to my post is what you may be looking for.
    – wch1zpink
    Jul 18, 2023 at 22:10
  • Oh, thank you so much!
    – jsx97
    Jul 18, 2023 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .