Is There a Way to Access a Specific App Preference Setting


#1

Hello,
In Scrivener (my question would apply to any app), there are many possible preferences. As per my illustration, each of the icons at the top (General, Editing, etc) has a corresponding series of options vertically, and more.
In terms of workflow, some of the preferences need to be changed frequently as I am working, for example the index card text font which is about 4 levels deep in Scrivener preferences. I would like to know if there is a KBM which would allow me to do so.
As far as I can see, the show menu item action stops as preferences.
thanks very much

image


#2

If Scrivener is scriptable, use AppleScript.
If Scrivener is not scriptable, use AppleScript GUI Script.

tell application "System Events"
    tell process "Scrivener"
        entire contents
    end tell
end tell

#3

thank you for your reply. I don't understand. What would happen if I create this apple script. What would be the output.
thank you


#4

It is up to you, I don't have Scrivener so I can only offer one line of thought.


#5

That is correct because that is where the menu items stop.
All of the other UI elements on the window are buttons or other objects.

You could probably write an AppleScript to access/get/set the various UI elements, but it will take some work.

The key to get started is to understand what are the UI elements on that window, and how to you access them. You can use Chris @ccstone's macro/script:
Front Window Analysis Tool for System Events
to get a list of UI elements on the FrontMost window like the below, which is for Evernote.
However, I will warn you that it is not easy to write such a script, unless you are already very familiar with UI scripting. You can search the forum for some examples that will help.

Example Preferences Window & UI Elements

application Process "Evernote"
  window Preferences
  group "Fonts"
   button "Select"
   static text "Note text:"
   button "Select"
   static text "Consolas 16"
   static text "Note plain text:"
   static text "Helvetica Neue 16"
   static text "Fonts"
  group "Format for “Insert Date” (⇧⌘D)"
   pop up button 1
   static text "Format for “Insert Date” (⇧⌘D)"
  group "Auto Format"
   checkbox "Keyboard shortcuts automatically create lists, lines, and emojis."
   static text "Auto Format"
  button 1
  button 2
  button 3
  toolbar 1
   button "General"
   button "Sync"
   button "Software Update"
   button "Clipper"
   button "Keyboard Shortcuts"
   button "Formatting"
   button "Context"
   button "Reminders"
   button "Scanning"
  static text "Preferences"

Example AppleScript

Here's an example script to help get you started

tell application "Evernote" to activate

tell application "System Events"
  tell application process "Evernote"
    tell window 1 -- Preferences
      tell toolbar 1
        (*
          button "General"
          button "Sync"
          button "Software Update"
          button "Clipper"
          button "Keyboard Shortcuts"
          button "Formatting"
          button "Context"
         button "Reminders"
         button "Scanning"
     *)
        
        tell button "Formatting" to perform action "AXPress"
      end tell
    end tell
  end tell
end tell


#6

thank you very much for the detailed and instructive answer. I will give it a try today and let you know how it goes.


#7

If you find that too difficult, and plan on needing other UI scripts, then you might want to invest in UI Browser, a bit steep at $55, but worth it if you write a lot of uI scripts.


#8

Accessibility Inspector.app is free.

Install XCode in the Mac App Store, you will get Accessibility Inspector in /Applications/Xcode.app/Contents/Applications/.


#9

@suliveevil @JMichaelTX
I will look into these apps. Thanks to both of you for your time and help


#10

thank you very much.
After reading your note, I searched youtube and came upon Dan Tomas' video on integrating UI browser and KBM.
I decided to buy UI browser and work from there.
thanks again very much.
By the way, if you post youtube videos, I would be most interested.
I searched for JMichaelTX but there are too many singers, crooners and rappers with similar names


#11

Thanks for your imput a couple of years ago JMichael. Incidentally I used my first macro with a variable today. One I down loaded from the discourse group. I failed to create my own for the task of file renaming with creation date. The one I downloaded worked and I sort of half understood it.

Long time since you took the trouble to explain 'variable' to me, well as it is used here. I kind of get it now and was familiar with the concept from math... I still find them tricky in KM as you can see. I thought it would be nice to touch base with you about it and thank you again for you effort, that was a couple of years ago; KM is a long term thing! Be well.


#12

@JMichaelTX has also been a big help in my understanding of KBM. If you counted all the people he has helped over the years, you could probably fill a large stadium !


#13

Sorry you had trouble finding my videos. I noticed the YouTube search changed "JMichaelTX" into "JMichael S", so it gave a list not related to me.

IAC, here is a list of my videos:
JMichaelTX YouTube Videos


#14

I very much enjoyed your videos and subscribed. thank you


#15

Hey @ronald,

You'll want to join the UI Browser User Group then.

UI Browser is very useful, but it's pretty hard to get started with it.

https://groups.yahoo.com/neo/groups/uibrowser/info

I'm a long-time user, so feel free to ask me questions off-list.

-Chris


#16

Hey Chris,

In my few years of AppleScripting, I managed to get through without UIBrowser. Only using the thingy that comes with Xcode (Accesibility Inspector) and ScriptDebugger, and, admittedly sometimes some scripts like this or your Window Analysis Tool.

I’m a bit out of business now, do you think it is still worthwhile to purchase UI Browser, given the presence (and usefulness) of the aforementioned tools?

Not criticizing your statement, just asking if you would still recommend to purchase it for an occasional UI Scripter.


#17

Tom, I'm obviously not Chris, but I'm somewhat in the same boat as you.
Personally, I have not found it worthwhile to buy UI Browser, when the tools you mention can get the job done most of the time, albeit a bit slower.

IMO, it really comes down to this: How often do you need to develop new UI scripts, and how complex are the windows that you need to script?

If you are frequently developing UI scripts for paying clients, then it is a no brainer. :wink:


#18

I will join. thank you very much !
I am surprised that there are only 25 members.


#19

Hey Tom,

I agree with JM's reply except for the “paying clients” part. If you frequently develop UI scripts then it will save you time (which is money) and hair-pulling, head-scratching, and various other forms of self-destruction.  :sunglasses:

I personally do quite a lot of UI-Scripting (usually unpaid), so for me it really is was a no-brainer when I (still hesitantly) plucked-down my money back in 2005 – it only took a few hours of use for me to realize what a good investment I'd made.

If you have extra bucks burning a hole in your pocket and like tools then by all means...

But do you need it? Probably not.

I've provided some pretty good tools for those who don't want to spend the money.

@CJK (somewhere on the forum) has provided a very nice script for getting a reference to the object under the mouse cursor. It's not as flexible as the way UI Browser does it, but it's still very useful.

Although I'm not very happy with Apple's incarnations of Accessibility Inspector, it is free and much better than nothing.

-Chris