Apple Script - How to click menu items inside menu of a button? - applescript

Please find the screenshot above for the element path. Apple script event throws an error while clicking click menu item "X" of menu 1 of button 3 of window "Movie Recording"

You have to click the button, wait a bit and then pick the menu item
activate application "QuickTime Player"
tell application "System Events"
tell process "QuickTime Player"
tell window "Movie Recording"
click button 3
delay 0.2
pick menu item "Maximum" of menu 1 of button 3
end tell
end tell
end tell

Related

Pivot monitor with apple script. Error : 'Can't get button'

tell application "System Preferences"activateend tell
tell application "System Events"
set _0 to "Standard"
set _90 to "90°"
set _180 to "180°"
set _270 to "270°"
set preference to application process "System Preferences"
click UI element "Displays" of scroll area 1 of window "System Preferences" of preference
delay 1
click button "Display Settings..." of window "Displays" of preference
set monitor to window "LG 4K HDR" of preference
click monitor
set options to pop up button 1 of tab group 1 of monitor
set portrait to value of options is _270
click options
if portrait then
--switch to landscape mode
click menu item _0 of menu 1 of options
else
--switch to portrait mode
click menu item _270 of menu 1 of options
delay 5
click UI element "Confirm" of sheet 1 of monitor
end if
end tell
tell application "System Preferences"quitend tell
Result: error "System Events got an error: Can’t get button "Display Settings..." of window "Displays" of application process "System Preferences"." number -1728 from the button "Display Settings..." of window "Displays" of application process "System Preferences"
The above code is an automator script that pivots my monitor works until Mojave. After I update my mac, it doesn't work.
I actually don't know much about Apple Script. I got an error from 'click button "Display Settings..." of window "Displays" of preference'. I was trying to change 'button' as 'UI element', index, and system language. It doesn't work.
I think the error is because the button name is an ellipsis character and not triple dots ...
Can you try replacing that line with this instead (Monterey):
click (first button of window "Displays" of preference whose title starts with "Display Settings")

How to close Safari preference window using AppleScript?

I am using the below script to enable developer menu.
tell application "Safari"
tell application "System Events"
tell process "Safari"
click menu item "Preferences…" of menu 1 of menu bar item "Safari" of menu bar 1
click button "Advanced" of toolbar 1 of window 1
click checkbox "Show Develop menu in menu bar" of group 1 of group 1 of window 1
-- delay 2
keystroke "w" using {command down} -- > not working
end tell
end tell
end tell
How to close the preference window? With keystroke "w" using {command down}, I am getting cannot The document cannot be closed while the script is running. error.
Also how to enable checkbox only if it is not enabled? Currently, if I run the script twice, it toggles.
Just click the first button of the first window and check the value of the checkbox
tell application "Safari"
tell application "System Events"
tell process "Safari"
click menu item "Preferences…" of menu 1 of menu bar item "Safari" of menu bar 1
click button "Advanced" of toolbar 1 of window 1
tell checkbox "Show Develop menu in menu bar" of group 1 of group 1 of window 1
if value is 0 then click it
end tell
click button 1 of window 1
end tell
end tell
end tell
This AppleScript code works for me using the latest version of macOS Mojave.
tell application "System Events"
tell application process "Safari"
set frontmost to true
end tell
keystroke "." using {command down}
end tell

Need applescript for clear cookie on MAC for Safari 8 browser

I need to perform below things using applescript.
Launch Safari,
click "Clear History and Website Data" on Safari menu bar,
click "Clear History" button,
close safari browser.
I have tried with below code:
tell application "Safari" to activate
tell application "System Events"
click menu item "Clear History and Website Data…" of menu "Safari" of menu bar item "Safari" of menu bar 1 of application process "Safari"
delay 1
click button "Clear History" of pop up "Safari"
quit
end tell
tell application "Safari" to activate
set frontmost to true
tell application "System Events"
tell process "Safari"
set frontmost to true
click menu item "Clear History…" of menu "History" of menu bar 1
delay 3
click button "Clear History" of sheet 1 of window 1
end tell
end tell
tell application "Safari" to quit

Applescript Check for Flash Player Update in System Preferences

I've made it to here:
tell application "System Events"
tell process "System Preferences"
tell window "Flash Player"
click radio button "Advanced" of tab group 1
tell scroll area "Advanced"
click button "Check Now" of window 2
end tell
end tell
end tell
end tell
but I can't get applescript to click the "Check Now" Button.
I'm thinking I need to add another tell application "System Events" to click the second area of the advanced tab, but so far I just get errors
This works perfectly at me:
tell application "System Events"
tell process "System Preferences"
tell window "Flash Player"
tell tab group 1
click radio button "Advanced"
tell scroll area 1
click button "Check Now"
end tell
end tell
end tell
end tell
end tell
In such cases the tool Accessibility Inspector is very helpful.

applescript for Adobe acrobat pro - running action from action wizard

I have a doubt in adobe acrobat pro..
I m using applescript to run a action from Adobe acrobat Pro => Tools => "action wizard".
actually it does only the first step in choosing the action "Rajni" from the action wizard,
but i cant click the button "Next" seen in the window, to go to the next step... and then click close button....
could any body help on this...
tell application "System Events"
tell application process "Acrobat"
tell application "Adobe Acrobat Pro" to activate
click the menu item "Rajni" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1
click button "Next" of window "Action: Rajni" -- here is the problem ........
end tell
end tell
Many thanks...
try to add some delay before clicking window.
click the menu item "Rajni" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1
delay 2
click button "Next" of window "Rajni"

Resources