He buscado mucho para esto, pero todas las respuestas hablan de cómo enfocar una ventana completa (o un diálogo ... que sigue siendo una ventana en realidad) a través de activate
etc.
Pero no pude encontrar ninguna forma de detectar si se seleccionó un elemento específico de la interfaz de usuario, si estaba enfocado, etc.
Escribí una secuencia de comandos de Apple que salta automáticamente a Alfred Create Custom Web Search, pero la secuencia de comandos falló cuando la pestaña de funciones no se seleccionó de forma predeterminada. Así es como se ve mi código :
tell application "System Events"
keystroke "," using command down
delay delay_time
tell process "Alfred Preferences"
delay delay_time
-- hack: to ensure that the the "Default results" button isn't selected
-- by default, we select another tab first, then select the "features" tab
click button "Appearance" of toolbar 1 of window 1
click button "Features" of toolbar 1 of window 1
delay delay_time
UI elements of scroll area 1 of window 1
-- bring the left menu to focus first (see hack above, without hack this would work sometimes only)
keystroke tab
Preferiría no hacer este truco desagradable (que hace que la aplicación parpadee rápidamente entre pestañas cada vez que llamo al atajo). Prefiero hacer una declaración if else simple. ¿Ideas?
Esto definitivamente funciona en mi sistema que ejecuta Alfred 3. Es posible que deba ajustar los tiempos de demora, pero tal como están ahora, este script funciona para mí.
activate application "Alfred Preferences"
delay 1.5
tell application "System Events"
tell process "Alfred Preferences"
click button "Features" of toolbar 1 of window "Alfred Preferences" of application process "Alfred Preferences" of application "System Events"
delay 1
set selected of row 3 of table 1 of scroll area 1 of window "Alfred Preferences" of application process "Alfred Preferences" of application "System Events" to true
delay 1
click button "Add Custom Search" of tab group 1 of window "Alfred Preferences" of application process "Alfred Preferences" of application "System Events"
end tell
end tell
abad
wch1zrosa
abad
wch1zrosa
abad
wch1zrosa
wch1zrosa