Search code examples
applescript

AppleScript error 1719


I've a problem with this applescript. Error 1719. Instruments app I need to set the new slider value to 2.

This is my code:

tell application "Instruments"
    activate
end tell

activate application "Instruments"

tell application "System Events"

    tell process "Instruments"

        keystroke "," using command down --Instruments menubar -> Preferences

        tell window 1
            click button "CPUs" of toolbar 1

            set value of slider 1 of group 1 to 2

        end tell        
    end tell    
end tell

Image

Thanks for help


Solution

  • It's a reference error.

    The slider is in group 1 of group 1. When using GUI scripting it's also recommended to wait for particular UI elements in case there are time-critical changes.

    activate application "Instruments"
    
    tell application "System Events"
        tell process "Instruments"
            keystroke "," using command down --Instruments menubar -> Preferences
            tell window 1
                click button "CPUs" of toolbar 1
                tell group 1 of group 1
                    repeat until exists slider 1
                        delay 0.2
                    end repeat
                    set value of slider 1 to 2
                end tell
            end tell
        end tell
    end tell