Here is the workflow I recorded:
-- Bring the window “Warnings ” to the front.
set uiScript to "click window 1 of application process \"Keynote\""
my do( uiScript)
-- Press ⌘W
set uiScript to "keystroke \"w\" using command down"
my do( uiScript)
-- Click the “File” menu.
set uiScript to "click menu bar item \"File\" of menu bar 1 of application process \"Keynote\""
my do( uiScript)
-- Reduce File Size
set uiScript to "click menu item \"Reduce File Size\" of menu 1 of menu item \"Advanced\" of menu 1 of menu bar item \"File\" of menu bar 1 of application process \"Keynote\""
my do( uiScript)
-- Click the “Reduce” button.
set uiScript to "click UI Element \"Reduce\" of sheet 1 of window 1"
my do( uiScript)
-- Click the “Upgrade” button.
set uiScript to "click UI Element \"Upgrade\" of sheet 1 of window 1"
my do( uiScript)
-- Click the “File” menu.
set uiScript to "click menu bar item \"File\" of menu bar 1 of application process \"Keynote\""
my do( uiScript)
-- PDF…
set uiScript to "click menu item 1 of menu 1 of menu item \"Export To\" of menu 1 of menu bar item \"File\" of menu bar 1 of application process \"Keynote\""
my do( uiScript)
-- Click the “Next…” button.
set uiScript to "click UI Element 13 of sheet 1 of window 1"
my do( uiScript)
--
set uiScript to "click image 1 of UI Element 1 of row 2 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window 1 of application process \"Keynote\""
my do( uiScript)
--
set uiScript to "click UI Element 1 of row 2 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window 1 of application process \"Keynote\""
my do( uiScript )
-- Click the “Export” button.
set uiScript to "click UI Element \"Export\" of sheet 1 of window 1 of application process \"Keynote\""
my do( uiScript )
-- Press ⌘S
set uiScript to "keystroke \"s\" using command down"
my do( uiScript )
-- Press ⌘W
set uiScript to "keystroke \"w\" using command down"
my do( uiScript )
end do