-2

I can read the value of a pop menu using this script but cannot set the value

tell application "System Events"
    tell process "App"

        set myOptionOne to get value of pop up button 1 of group 3 of group 2 of scroll area 1 of group 3 of window 1

    end tell
end tell

I tried

set myOptionOne to set value of pop up button 1 of group 3 of group 2 of scroll area 1 of group 3 of window 1 

but having an error

I would rather be able to set the option without using keystroke.

I have an alternative script but again for clicking instead setting a value

set uiScript to "click menu item \"~ Other\" of menu 1 of pop up button 2 of group 2 of group 2 of scroll area 1 of group 3 of window 1 of application process \"App\""
  • 1
    You've said you're ‘having an error’ but what error is that? Have you tried removing the variable assignment? – grg May 4 '18 at 7:24
  • Expected expression but found “set”. yes I tried and have same issue without – Kevin May 4 '18 at 7:37
  • Where are you passing in what you want to set it to? You've told it to set the value but haven't given it your new value that you want it set to? – grg May 4 '18 at 16:54
1

AppleScript has a syntax that follows the form:

set something to somethingelse

Your code of "set myOptionOne to set value" therefor cannot be valid.

Here a sample that uses UI scripting that fills a textfield and presses enter in Safari:

tell application "Safari"
    activate
    open location "http://google.com"
    delay 1
end tell

tell application "System Events"
    tell process "Safari"
        tell group 2 of group 4 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "Google"
            set value of combo box 1 to "Sean Bean"
            delay 1
            key code 36 -- Enter key
        end tell
    end tell
end tell

You can also shorten the code and avoid the "pyramid of doom" by using instead of (example code):

tell application "Something"
    set value of combo box to "some value"
end tell

you just state like this:

tell application "Something" to set value of combo box to "some value"
  • Thank you I validated your answer but is not working for me, I guess it's should be the app it self. I already use this in the pass without issue – Kevin May 5 '18 at 9:10
  • @LowRisk When you say it's not working does that mean that the script compiles but the field doesn't change or that the script does not compile? Without knowing which application you are trying to script I'm afraid I can't be more specific with help. – boris42 May 5 '18 at 9:35
  • The script compiles but with no result ( if I do without set value the script found the windows) but when I add set value there is no action, I guess there is a limitation on the app – Kevin May 5 '18 at 9:39
  • @LowRisk Is this a well known app that I could try it with? – boris42 May 5 '18 at 9:40
  • Business / internal app unfortunately – Kevin May 5 '18 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .