Esta es una continuación de un post realizado hace unos 2 años para utilizar el script de Apple para cambiar entre redes Wi-Fi a través de la barra de menús:
Big Sur 11.1: AppleScript para cambiar automáticamente las redes Wi-Fi
Mi script, que antes funcionaba, ahora sólo devuelve "missing value":
tell application "System Events" to click (every menu bar item of menu bar 1 of application process "ControlCenter" whose title starts with "WiFi")
tell application "System Events" to click (every UI element of scroll area of group 1 of window "Control Center" of application process "ControlCenter" whose title starts with "YOUR_SSID_HERE")
Parece que MacOS Ventura rompió mi solución anterior bastante mal. Ya ni siquiera puedo usar "get properties" para tener algún sentido de lo que debería ser la jerarquía de los elementos de la UI. Ej:
tell application "System Events" to click (every menu bar item of menu bar 1 of application process "Control Center" whose description starts with "WiFi")
delay 3
tell application "System Events" to get properties of UI elements of scroll area 1 of group 1 of window "Control Center" of application process "Control Center"
Resultado:
{{minimum value:missing value, orientation:missing value, position:{2061, 76}, class:UI element, accessibility description:missing value, role description:"heading", focused:missing value, title:missing value, size:{102, 15}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXHeading", value:missing value, subrole:missing value, selected:missing value, name:missing value, description:"heading"}, {minimum value:missing value, orientation:missing value, position:{2052, 95}, class:checkbox, accessibility description:missing value, role description:"toggle button", focused:missing value, title:missing value, size:{288, 32}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXCheckBox", value:0, subrole:"AXToggle", selected:missing value, name:missing value, description:"toggle button"}, {minimum value:missing value, orientation:missing value, position:{2061, 141}, class:UI element, accessibility description:missing value, role description:"heading", focused:missing value, title:missing value, size:{99, 15}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXHeading", value:missing value, subrole:missing value, selected:missing value, name:missing value, description:"heading"}, {minimum value:missing value, orientation:missing value, position:{2052, 160}, class:checkbox, accessibility description:missing value, role description:"toggle button", focused:missing value, title:missing value, size:{288, 32}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXCheckBox", value:0, subrole:"AXToggle", selected:missing value, name:missing value, description:"toggle button"}, {minimum value:missing value, orientation:missing value, position:{2052, 192}, class:checkbox, accessibility description:missing value, role description:"toggle button", focused:missing value, title:missing value, size:{288, 32}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXCheckBox", value:1, subrole:"AXToggle", selected:missing value, name:missing value, description:"toggle button"}, {minimum value:missing value, orientation:missing value, position:{2052, 224}, class:checkbox, accessibility description:missing value, role description:"toggle button", focused:missing value, title:missing value, size:{288, 32}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXCheckBox", value:0, subrole:"AXToggle", selected:missing value, name:missing value, description:"toggle button"}, {minimum value:missing value, orientation:missing value, position:{2052, 267}, class:UI element, accessibility description:missing value, role description:"disclosure triangle", focused:false, title:missing value, size:{288, 22}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXDisclosureTriangle", value:0, subrole:missing value, selected:missing value, name:missing value, description:"disclosure triangle"}}
Esto es un total galimatías para mí y no enumera ningún elemento claro de la interfaz de usuario con ningún nombre o atributos de descripción que apunten a un SSID Wi-Fi específico. También observo un montón de cadenas de "valores perdidos". En comparación, utilizando el Inspector de Accesibilidad y haciendo clic en mi SSID deseado en la lista de redes, afirma que tiene los siguientes atributos:
<AXApplication: “Control Center”>
<AXWindow: “Control Center”>
<AXGroup>
<AXScrollArea>
<AXCheckBox>
Attributes:
AXParent: “<AXScrollArea>”
AXRoleDescription: “toggle button”
AXChildren: “<array of size 0>”
AXIdentifier: “wifi-network-MYSSID”
AXPath: “Path 0x600003016d90:
”
AXAttributedDescription: “MYSSID, secure network, 3 bars{
AXATextAlignmentValue = 0;
AXFont = {
AXFontFamily = ".AppleSystemUIFont";
AXFontName = ".SFNS-Regular";
AXFontSize = 13;
AXVisibleName = "System Font Regular";
};
AXForegroundColor = <CGColor 0x6000026161c0> [<CGColorSpace 0x600002620ae0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Generic RGB Profile)] ( 0 0 0 0.847059 );
}”
AXEnabled: “1”
AXSubrole: “AXToggle”
AXRole: “AXCheckBox”
AXWindow: “<AXWindow: “Control Center”>”
AXValue: “1”
AXChildrenInNavigationOrder: “<array of size 0>”
Actions:
AXPress - press
Estoy realmente perplejo aquí y he estado tratando de trabajar en esto durante horas. No puedo, por mi vida, averiguar qué elemento hijo dentro del "área de desplazamiento 1" debería utilizar. ¿Alguna idea?
Gracias.