Minor Scriptability Quesiton

  • In Applescript, I can click a checkbox in my application like so:

    tell application "System Events"
    tell process "MyApp"
      tell window "MyWindow"
      click checkbox 4
      end
    end
    end

    The button identified by "checkbox 4" has no visible title (just the icon), but I did set a title so the button technically has one, but it isn't usable by Applescript. I thought this might mean I'd have to do

    [button accessibilitySetValue:@"My Title" forAttribute:NSAccessibilityTitleAttribute];

    But that resulted in:
    "AXTitle" attribute unsupported by: <NSButton: 0x224d1e0>

    It seems that NSButton/NSControl doesn't have the ability to use a custom AXTitle and also doesn't export the non-visible title.

    Any thoughts on what I should do to be able to name the button for accessibility?

    --
    Seth Willits
  • On May 14, 2013, at 4:55 PM, Seth Willits wrote:

    > Any thoughts on what I should do to be able to name the button for accessibility?

    Addendum:

    Discovered -accessibilitySetOverrideValue:forAttribute: but that has no effect. The title is still empty.

    --
    Seth Willits
  • On 15/05/2013, at 9:55 AM, Seth Willits <slists...> wrote:

    > [button accessibilitySetValue:@"My Title" forAttribute:NSAccessibilityTitleAttribute];

    > Discovered -accessibilitySetOverrideValue:forAttribute: but that has no effect. The title is still empty.

    The docs for the latter say: "Ensure that you invoke this method on the actual object that represents the user interface element. For example, in the case of NSButton, use the underlyingNSButtonCell. The NSButton itself is ignored by accessibility." That suggests it also applies to the former.

    --
    Shane Stanley <sstanley...>
    'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
  • On May 14, 2013, at 6:19 PM, Shane Stanley wrote:

    >> [button accessibilitySetValue:@"My Title" forAttribute:NSAccessibilityTitleAttribute];
    >
    >> Discovered -accessibilitySetOverrideValue:forAttribute: but that has no effect. The title is still empty.
    >
    > The docs for the latter say: "Ensure that you invoke this method on the actual object that represents the user interface element. For example, in the case of NSButton, use the underlyingNSButtonCell. The NSButton itself is ignored by accessibility." That suggests it also applies to the former.

    Excellent! (Silly me.)

    With just that I can make a few things easier through scripting without having to dive into anything else.

    Thanks,

    --
    Seth Willits
  • On 16/05/2013, at 2:19 AM, Seth Willits <slists...> wrote:

    > With just that I can make a few things easier through scripting without having to dive into anything else.

    I was afraid that was where you were headed. Really, GUI scripting is a finnicky, unreliable hack. Unless you need a complex object model, implementing proper scriptability isn't generally that hard (documentation issues aside). If you just want to expose a a few properties or commands, it's very simple.

    --
    Shane Stanley <sstanley...>
    'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today