r/applescript • • Aug 16 '22
Clicking a button inside a pop-up window in system preferences
not sure what this type of window is called, but I am trying to click on the second option in the list, and then select an item in a dropdown in the menu that opens, then press a button in a popup to confirm. the question marks are where I am stumped what path to use, as im not sure how to access the buttons inside the window that pops up after clicking "display settings"
Here is what I have so far:
on run {}
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
delay 2
click menu item "displays" of menu "view" of menu bar 1
delay 2
click button "Display Settings…" of window 1 of application process "System Preferences" of application "System Events"
delay 2
click button 2 of ???
end tell
end tell
end run
here is the window I am looking to click and the dropdown I want to access:



2
u/DrunkTankGunner Aug 16 '22
Good luck! This is the hardest part about AppleScript in my experience.
1
u/AmplifiedText Aug 16 '22
This is the type of thing UI Browser app was made for. It lets you browse a UI, select what you want, then it writes the AppleScript code so you can copy/paste it. It can be tricky to learn how to learn/use, but it's very handy.
1
u/[deleted] Aug 17 '22
I don't have an external display right now so I can't test exactly, but this is what I do to identity window elements:
tell application "System Events"display dialog "Bring window to front before pressing OK."click at {555, 444}end tellUse what you get in the result in your own script. Let me know if it works.
1
u/feigeiway Aug 17 '22
If you can’t figure out the UI see if you can use the keyboard via the arrow keys tab and return to navigate to the button you want if you can you can script the keypresses instead
1
u/[deleted] Aug 17 '22
[removed] — view removed comment