Hi everyone, having trawled every corner of Google and this forum for an answer I’m at a dead end…
In essence I’m looking to write a script that changes the refresh rate of an external monitor connected to a mac mini. I’ve got really close but I can’t seem to find the command that selects a value in a pop up menu.
This is what I’ve got so far
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.display”
end tell
delay 0.5
tell application “System Events”
click menu item “50 Hertz (PAL)” of menu 1 of pop up button 1 of window 1 of process “System Preferences”
end tell
end tell
I guess there needs to be some sort of unique identifier for that pop up button but I can’t see one anywhere in Accessibility Inspector and I’ve tried inputting the “identifier” but still no joy. Any help with this would be greatly appreciated it’s driving me nuts!
Cheers
Dicky
Model: Mac Mini
AppleScript: 2.7
Browser: Firefox 42.0
Operating System: Mac OS X (10.10)
As far as I know you are starting with a wrong pane identifier.
Try this code :
tell application "System Preferences"
activate
tell pane id "com.apple.preference.displays"
name of every anchor --> {"displaysArrangementTab", "displaysColorTab", "displaysGeometryTab", "displaysDisplayTab"}
# Reveal the wanted anchor
# As I own an iMac only "displaysDisplayTab" and "displaysColorTab" are viewable
reveal anchor "displaysDisplayTab"
end tell
end tell
(*
# These instructions are just an example applying to the Sound pane
tell application "System Events"
tell process "System Preferences"
try
tell (1st row of table 1 of scroll area 1 of ¬
tab group 1 of window "sound" whose value of text field 1 is "32LG2000")
set selected to true
end tell
end try
end tell
end tell
quit application "System Preferences"
*)
As you may read in the code, I may just display a couple of anchors. There is no item resembling to the one you want to trigger in them.
Hi guys,
Just to let people know, I eventually got this sorted, turns out I was on the right track but when selecting pop up buttons you have to go about it in a different format…
Anyway, this is what I ended up with to select a menu value in the pop up button
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.general”
end tell
delay 0.5
tell application “System Events”
tell pop up button 1 of window 1 of process “System Preferences”
click
tell menu 1
click menu item “Graphite”
end tell
end tell
--click menu item "Blue" of menu of pop up button 1 of window "General" of process "System Preferences"
end tell
Hopefully this can be some use if others are stuck, cheers for the help
You have to use GUI-Scripting for this, but it can be done.
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
# Example 1
click button "Other Bookmarks"
# Example 2
click button "Inbox (7)"
# Example 3
tell (first button of toolbar 1 whose accessibility description is "1Password")
# Demonstrate two different actions.
perform action "AXShowMenu"
perform action "AXPress"
# NOTE: AXPress pops up the 1Password dialog under the mouse pointer.
end tell
end tell
end tell
end tell
Using System Events for GUI-Scripting is frequently not straightforward at all, so you have to learn how to excavate the terminology you need. I use UI Browser myself, but most folks won’t pony-up the $55.00 U.S. for it. There is a demo though.