I am new to AppleScript, Macs, and computers in general, so I’ll apologize in advance if I missed something blindingly obvious (in my defense, I am a stay at home Dad with 2 “helpful” children under 4 years old.)
What I am trying to create is a script to switch my startup disk to its clone - on an external drive - then restart. I want to save it as an application and give it a Butler hot key short cut. I found information about rebooting in Classic, but I have no idea how to adapt it to my needs. I ended up trying a GUI approach.
Using trial and error, UI Element Inspector, and UI Element script examples, I managed to get this to compile:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.startupdisk"
end tell
tell application "System Events"
if UI elements enabled then
tell process "System Preferences"
click button 3 of radiogroup of ScrollArea of group of SplitGroup of window "Startup Disk" of process "System Preferences"
end tell
else
tell application "System Preferences"
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\" at the bottom left of this pane."
end tell
end if
end tell
tell application "System Events" to restart
but when run it results in " System Events got an error: Can’t make button 3 of radiogroup of ScrollArea of group of SplitGroup of window “Startup Disk” of process “System Preferences” of process “System Preferences” into type UI element."
UI Element inspector provides the following information when I hold the cursor over my clone in System Preferences. I’m confused by not being able to make the AXButton “Mac OS X, 10.4.6 on jClone” into a UI element.
<AXApplication: “System Preferences”>
<AXWindow: “Startup Disk”>
<AXButton: “Mac OS X, 10.4.6 on jClone”>
Attributes:
AXRole: “AXButton”
AXRoleDescription: “button”
AXHelp: “Volume: jClone
System: Mac OS X, 10.4.6 (8I127)”
AXEnabled: “1”
AXFocused (W): “0”
AXParent: “”
AXWindow: “<AXWindow: “Startup Disk”>”
AXTopLevelUIElement: “<AXWindow: “Startup Disk”>”
AXPosition: “x=308.5 y=198”
AXSize: “w=136.25 h=83”
AXTitle: “Mac OS X, 10.4.6 on jClone”
Actions:
AXPress - press
I would be grateful to anybody who could steer me in the right direction. Thanks in advance.
j