Wednesday, December 8, 2021

#1 2014-01-30 10:11:02 pm

Derick
Member
Registered: 2007-05-26
Posts: 18

UI Scripting: click broken in 10.9 -NOT an accessibility pref. issue

I had the following script working fine until upgrading to Mavericks, to semi-automating saving Keynote presentations as PDFs with specific settings:

Applescript:

tell application "System Events"
   tell application process "Keynote"
       set frontmost to true
       
       repeat until window 1 exists
       end repeat
       
       -- Hide Inspector if visible    
       if menu item "Hide Inspector" of menu 1 of menu bar item "View" of menu bar 1 exists then
           keystroke "i" using {command down, option down}
       end if
       
       -- Print; wait until the sheet is visible    
       click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
       
       repeat until sheet 1 of window 1 exists
       end repeat
       
       click ((pop up buttons of sheet 1 of window 1) whose description is "Presets")
       click menu item "6x" of menu of ((pop up buttons of sheet 1 of window 1) whose description is "Presets") --replace if desired with your preferred preset
       
       if value of (checkbox 1 of sheet 1 of window 1) is 0 then
           click (checkbox 1 of sheet 1 of window 1)
       end if --set to print selected slides only -- you can use the same technique to adjust other checkboxes as desired
       
       click radio button "Individual Slides" of radio group 1 of sheet 1 of window 1 --replace to suit your needs
       
       click menu button "PDF" of sheet 1 of window 1
       click menu item "Save as PDF…" of menu 1 of menu button "PDF" of sheet 1 of window 1 -- Save as PDF...
   end tell
end tell

end open

This worked fine.  Now, when I run it, I get the message

System Events got an error: every pop up button of sheet 1 of window 1 of application process "Keynote" whose description = "Presets" doesn’t understand the “click” message.

on the line

Applescript:

click ((pop up buttons of sheet 1 of window 1) whose description is "Presets")

I've found a couple of other posts that make me think that click has stopped working for some UI elements in Mavericks.  It clearly still works for some items, & accessibility prefs. are ok, b/c the prior click menu item command runs fine.

Any help would be much appreciated!


Filed under: GUI scripting, mavericks

Offline

 

#2 2014-01-31 07:55:18 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4622

Re: UI Scripting: click broken in 10.9 -NOT an accessibility pref. issue

Try :
set thePopUp to first  pop up button of sheet 1 of window 1 whose description is "Presets"
click thePopUp
click menu item "6x" of menu 1 of thePopUp--replace if desired with your preferred preset

Yvan KOENIG (VALLAURIS, France) vendredi 31 janvier 2014 14:54:35

Last edited by Yvan Koenig (2014-01-31 07:55:47 am)

Offline

 

#3 2014-01-31 11:59:30 am

Derick
Member
Registered: 2007-05-26
Posts: 18

Re: UI Scripting: click broken in 10.9 -NOT an accessibility pref. issue

Thanks for the help!  This works perfectly.  Not sure why it would change in Mavericks but glad to find a solution! smile:):)

Offline

 

#4 2014-01-31 02:48:57 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4622

Re: UI Scripting: click broken in 10.9 -NOT an accessibility pref. issue

I use the syntax
first  pop up button of sheet 1 of window 1 whose description is "Presets"
for years.

I don't understand how a script would be able to click:
(every  pop up button of sheet 1 of window 1 whose description is "Presets")
as you were asking it to do.

The error message was explicit  (no, not like Miley Cyrus)
System Events got an error:
every pop up button of sheet 1 of window 1 of application process "Keynote" whose description = "Presets"
doesn’t understand the “click” message.

I used a variable just to don't scan twice the set of pop up buttons.

Yvan KOENIG (VALLAURIS, France) vendredi 31 janvier 2014 21:45:55

Offline

 

#5 2014-01-31 11:07:57 pm

Derick
Member
Registered: 2007-05-26
Posts: 18

Re: UI Scripting: click broken in 10.9 -NOT an accessibility pref. issue

Yeah, the every line doesn't make a lot of sense now that I look at it....but it had worked fine for me for 9 months or so, until I upgraded to Mavericks.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)