Hi All,
I write a script (applet) to turn on wi-fi, using UI Browser and have Calender run it at 5 am. When run by Calendar, an error occurs (see below). The script is opened in Script Editor and the line click button “Turn Wi-Fi On” of group 1 of window “Network” is highlighted as the problem.
However, if I run it via Apple Script Editor or Script Debuggger, it runs fine without any problems.
(This is the error message)
Can’t get <> “Turn Wi-Fi On” of <> 1 of window “Network” of <> “System Preferences” of application “System Events”.
System Events got an error: Can’t get button “Turn Wi-Fi On” of group 1 of window “Network” of process “System Preferences” . (-1728)
(This is the code)
tell application “System Preferences”
activate
tell application “System Events”
activate
tell process “System Preferences”
set frontmost to true
click menu item “Show All Preferences” of menu 1 of menu bar item “View” of menu bar 1 — Show all Prefs
delay 1
click button “Network” of scroll area 1 of window “System Preferences” — Select NETWORK Prefs
delay 1
select row 6 of table 1 of scroll area 1 of window “Network” — Select Wi-Fi
delay 1
click button “Turn Wi-Fi On” of group 1 of window “Network” — Turn Off Wi-Fi
delay 1
click menu item “Show All Preferences” of menu 1 of menu bar item “View” of menu bar 1 — Show all Prefs
click menu item “Energy Saver” of menu 1 of menu bar item “View” of menu bar 1 — Select ENERGY SAVER Prefs
click button “Restore Defaults” of group 1 of window “Energy Saver” — Select default settings
—click checkbox “Put hard disks to sleep when possible” of group 1 of window “Energy Saver” — Turn ON & OFF checkbox.
end tell
end tell
end tell
What am I doing wrong?
Help.
Willis
Model: MiniMac
AppleScript: 2.4
Browser: Chrome 78.0
Operating System: macOS 10.10