Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Scripting the International preference pane System
Recently, I had a need at work for an AppleScript to toggle between the US and UK number formats, located in the "International" Preference Pane under the "Formats" section. Well, actually, my boss had a need. Which, of course, means I had a need. I did a bunch of digging on and various scripting sites, and found that I could do it with "Enable access for assistive devices" turned on (Universal Access prefs panel), and using Prefab's UI Browser application to identify the UI elements.

However, I had trouble selecting the "International" preference pane -- it turns out that it's not named or anything like that. A scan through the filesystem (using the Terminal) showed me that it was really named, based on seeing and exploring the Localization.prefPane directory under /System -> Library -> PreferencePanes. That worked. It's interesting that some of the preference pane names are what you'd expect, while others are not.

As a side note, somewhere (I forget where), I found an AppleScript code fragment that helped identify the pane correctly after I figured it out from the resource files:

tell application "System Preferences"
  get name of current pane
end tell

Also, if anybody is interested, here is the basic AppleScript. Maybe it will save somebody else some time.
(* A quick-n-dirty way to select a Number Format
   From the "International" Preference Pane.
   Note that you need the "Enable access for 
   assitive devices" option turned on in the 
   "Universal Access" preference pane for this to work *)

(* Also, there is no error checking.  Caveat emptor. *)

(* Fire up System Preferences *)
tell application "System Preferences"
  (*	Guess what?  It's not named *)
  set current pane to pane ""
end tell

(* 	Now, hook up with the System Events and pretend
	that we are using the GUI. *)
tell application "System Events"
  tell application process "System Preferences"
    (* Tab group 1 is most elements in the pane. *)
    click radio button "Formats" of tab group 1 of window "International"
    (* Make the menu pop up. *)
    click pop up button 1 of tab group 1 of window "International"
    (* Pick seems to work well in this case. *)
    pick menu item "United Kingdom" of menu of 
     pop up button 1 of tab group 1 of window "International"
  end tell
end tell
(* Bail out, now that we're done. *)
tell application "System Preferences" to quit
  • Currently 1.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)

Scripting the International preference pane | 2 comments | Create New Account
Click here to return to the 'Scripting the International preference pane' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Scripting the International preference pane
Authored by: Accura on Jul 14, '04 07:16:20PM

Nicely written and commented script


"The time has come," the walrus said. "To talk of many things..."

[ Reply to This | # ]
An easier way to find out pane names
Authored by: Montreal on Jul 16, '04 06:36:14AM
You can get the names of all the panes with the following simple script:
tell application "System Preferences"
    get name of panes
end tell
(Originally posted here by ranker.)

[ Reply to This | # ]