Reputation: 1
I have the window of the picture above, save the configuration through stand-alone save, AppleScript can not click Save through click, the following script returns missing value, please ask in AppleScript, how to click static text
tell application "System Events"
tell process "WeChat"
click menu item "Proxy Settings..." of menu "WeChat" of menu bar 1
click radio button "Don't Use" of window "Proxy Settings"
delay 1
set focused to true
click static text "Save" of window "Proxy Settings"
end tell
end tell
```[enter image description here](https://i.sstatic.net/ZWJ9V.png)
tell application "System Events" tell process "WeChat" click menu item "Proxy Settings..." of menu "WeChat" of menu bar 1 click radio button "Don't Use" of window "Proxy Settings" delay 1 set focused to true click static text "Save" of window "Proxy Settings" end tell end tell
Upvotes: 0
Views: 757
Reputation: 1
"Save" is not a button, and only one button can be found through the UI element, this button is a close button, and nothing else.
Upvotes: 0
Reputation: 6092
I don't have/use WeChat, so cannot examine the UI to confirm here, but static text
elements—generally speaking—don't often have actions
attached to them ("AXPress"
is the name of the action
that the click
command aliases). From a design perspective, static text
elements are intended as an inert label for some other UI element
that plays a functional role. In this case, it looks like a button
element, and its name is probably also "Save"
. button
elements are also good candidates for attaching a whole bunch of actions
to.
Therefore, instead of:
click static text "Save" of window "Proxy Settings"
you could try:
click button "Save" of window "Proxy Settings"
If that throws an error, it'll either be because the button
element's name is not "Save"
, or the element is not a button
. But you can find out what it is like this:
-- click button "Save" of window "Proxy Settings"
tell window "Proxy Settings" to get (the last UI element ¬
where the name of its actions contains "AXPress")
This will yield a reference to the object you're trying to click, by virtue of its actions
necessarily containing one named "AXPress" (i.e. it responds to the click
command), and its physical positioning almost certainly inferring it to be the last such UI element
.
Upvotes: 0