GUI scripting the label pop-up

Anybody tried this? Got problems with the “click menu item of menu 1 of pop up button 3 of group 1 of splitter group 1” construct. Where might the likely culprit be?

I haven’t tried such a scripting myself, but here are some thoughts…

Might just be a typo, but in your example you did not actually specify what menu item you wanted to have clicked.

UI Inspector reports the following:

<AXApplication: “Scrivener”>
<AXWindow: “Strange Fiction.scriv”>

<AXMenuItem: “Blue”>

Looks like a second SplitGroup is in the hierarchy have you accounted for it in your call?

BTW, what about scripting the label options on the “gear” pop-up under the binder area instead? This would have the virtue of working without the Inspector being open. I don’t know about you but my Binder is open a lot more than my Inspector when I work. UI Inspector shows the following for a label option on that pop-up:

<AXApplication: “Scrivener”>
<AXWindow: “Whatever.scriv”>

<AXMenuButton: “dummy”>

<AXMenuItem: “Label”>

<AXMenuItem: “Red”>

  1. This is something I would first try to tackle with QuicKeys (key macro program), because if I could get it running that way, I would not have to handle the gui scripting myself.


The problem might just be that Scrivener is not currently properly AppleScriptable. In testing out how difficult it would be to add, I exposed the app to AppleScripting, but went no further as it became obvious that it would be a big job. Thus AS is currently crippled - I intend to add proper support in the future but can’t say when. It’s on my list for further investigation for the next update, but I doubt it will make it in simply because of the scale of how much code I would have to expose to AppleScript in order for it to be useful.
All the best,

Glad to report that it now works like a charm - by using “click by position” (first get location of menu item, then click it) rather than “clik menu item”.

Agree that this is something for Quickeys, but I am avoiding Qk when I can.

I do not think that the fact that Scriv is not Appescript ready should anything for the ability to GUI script it. Or am I mistaken?

GUI scriptiing does not presuppose or require that an application be Applescriptable. In fact, it is typically resorted to to script things in apps that are not Applescriptable or have not made some function accessible via Applescript.

Glad you found a solution, nordlys.