• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Backlight using GUI scripting doesn't work...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Backlight using GUI scripting doesn't work...


  • Subject: Re: Backlight using GUI scripting doesn't work...
  • From: kai <email@hidden>
  • Date: Mon, 9 Oct 2006 00:29:53 +0100


On 8 Oct 2006, at 22:13, hackmiester (Hunter Fuller) wrote:

On 7 October 2006, at 18:45, kai wrote:

The problem is similar to that outlined in my recent reply to Peter Baxter, Hunter. Try:

----------------

tell application "System Preferences" to reveal anchor ¬
	"displaysDisplayTab" of pane id "com.apple.preference.displays"

tell application "System Events" to tell slider 1 of ¬
	group -1 of tab group 1 of window 1 of ¬
	process "System Preferences" to set value to 1

----------------

Thank you! This works perfectly! However, to be honest, I still have no idea why. Can you elaborate?

Sure, Hunter.

The first line of the script reveals not only the relevant pane, but also the required tab (anchor). Since execution won't proceed until the anchor is revealed, this method not only reduces the clicks required in the UI; it also avoids some of the timing issues that might arise, following a click, while waiting for the target element to appear.

The script's second line defines the path to the target UI element - which is structured as follows:

--------
window 1
--------
3 buttons ("close", "zoom", "minimize")
1 static text (reflecting the window's title)
1 tool bar
1 tab group (* this is obviously the one we want *)

----------------------
window 1 / tab group 1
----------------------
2 radio buttons (representing the tabs: "Display" & "Color")
2 groups

The first of these two groups contains most of the displayed elements...

--------------------------------
window 1 / tab group 1 / group 1
--------------------------------
1 scroll area ("Resolutions:")
2 pop up buttons ("Colors:" & "Refresh Rate:")
2 buttons ("Detect Displays" & "Help")
1 checkbox ("Show displays in menu bar")
3 static texts (the labels for the scroll area & pop up buttons)

However, we still haven't found our slider - so let's move on to:

--------------------------------
window 1 / tab group 1 / group 2
--------------------------------
1 static text ("Brightness")
1 slider (eureka!)

So your original script was trying to locate the slider in group 1, while it was actually tucked away in group 2.

The reason I referred to this as the last group (-1), rather than the second (2), is in case additional groups are added in future. Should that happen, the chances are that the one containing the slider will be moved to accommodate them - and thus will remain the last group. (Nothing's certain, of course, but the technique already works quite well with windows containing elements that can be toggled - such as tool bars, or the Address/Bookmarks/Status/Tab bars in Safari, for example.)

I hope that clears up some of the confusion, but yell if my attempt to explain it doesn't do the trick...

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Backlight using GUI scripting doesn't work...
      • From: "hackmiester (Hunter Fuller)" <email@hidden>
    • Re: Backlight using GUI scripting doesn't work...
      • From: Bill Cheeseman <email@hidden>
References: 
 >Backlight using GUI scripting doesn't work... (From: "hackmiester (Hunter Fuller)" <email@hidden>)
 >Re: Backlight using GUI scripting doesn't work... (From: kai <email@hidden>)
 >Re: Backlight using GUI scripting doesn't work... (From: "hackmiester (Hunter Fuller)" <email@hidden>)

  • Prev by Date: Re: Backlight using GUI scripting doesn't work...
  • Next by Date: Re: ScreenSaver settings
  • Previous by thread: Re: Backlight using GUI scripting doesn't work...
  • Next by thread: Re: Backlight using GUI scripting doesn't work...
  • Index(es):
    • Date
    • Thread