1

i was write a simple code to click share button on Notes applicaion

set upArrow to ASCII character 30
activate application "Notes"
tell application "System Events"
tell process "Notes"
set frontmost to true
click button 2 of group 2 of splitter group of window 1
keystroke upArrow
keystroke return
end tell
end tell

the problem is

click button 2 of group 2 of splitter group 1 of window 1 of application process "Notes" --> missing value

it need 6s to complete run this and return error missing value

but if i dont add keystroke or any command follow that, this code work perfectly

6
  • are you running this within Script Editor or as an applet or? Mar 16, 2013 at 7:20
  • i running this on applescript editor
    – nemtabi
    Mar 16, 2013 at 7:23
  • Your script works for me, at least on my machine. It brings up the "send via message" functionality within Notes. The only difference I see between what I have and what you have (in your screenshot) is that you are doing "tell application "System Events" ***to*** tell process "Notes"", which I think is a wee bit incorrect. Mar 16, 2013 at 7:30
  • it just another method to use tell function, what is your os, i used mountain lion. Do you have "missing value" when run the code.
    – nemtabi
    Mar 16, 2013 at 8:38

3 Answers 3

1

I also get that delay and it returns missing value. But could you click a menu bar item instead?

activate application "Notes"
tell application "System Events" to tell process "Notes"
    click menu item "Email" of menu 1 of menu item "Share" of menu "File" of menu bar 1
end tell
0
0
set focused of button 2 of group 2 of splitter group 1 of window 1 to true
keystroke space

or

set value of attribute "AXFocused" of button 2 of group 2 of splitter group 1 of window 1 to true
keystroke space

Source:

https://lists.apple.com/archives/Accessibility-dev/2006/Oct/msg00013.html

0

There is a thread that seems to describe the same bug that appears to be limited to specific software. It is on MacScripter.net: Script delays on clicking button (controlling Sys Prefs pane)

Note the most recent post that describes a delay in FileMaker. It seems like the only work-around when software exhibits this bug is to do something else to open the new window. If the only way to run the desired function is via a button, one (terrible) option is clicking at coordinates relative to the corner of the front window. Obviously this will easily fail if the content can move relative to the corner or if a new version of the software moves the button desired. Any other ideas?

UPDATE, 2023-02-13:

In case anybody is still dealing with this bug, here's some useful AppleScript to get the coordinates of the object you'd like to click. You can then feed those into some coordinate-clicking utility, like cliclick (binary), Python code, Keyboard Maestro, and so on.

tell application "System Events"
  set someObject to <REFERENCE TO YOUR OBJECT>
  -- e.g. op's: button 2 of group 2 of splitter group of window 1 of application process "Notes"

  set {xCoord, yCoord} to position of someObject
  set {xSize, ySize} to size of someObject
end tell
set objOffset to round (minNum({xSize, ySize}) / 2) rounding down
set xClick to xCoord + objOffset
set yClick to yCoord + objOffset
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.