Friends
Unless I’ve missed it, the Notes app, while having its own scripting suite, fails to provide any way to open a given note. So while it’s great that you can search and retrieve notes via a script, you can’t actually tell Notes to show or display a note that you specify.
If I’m wrong about that, can someone point me to what I’ve missed (and there’s no need to read any further)?
OTH, if I’m right, it appears we must fall back to the ever un-trustworthy GUI scripting technique. My approach is to fill in Notes' search field with the note name and then get the search field to send its action to its target (aka ‘Click’).
Alas, and occasioning not the least surprise on my part, I’m having problems making this work reliably. It’ll work a couple of times, then it’ll fail. In particular, if I clear the search field with the little ‘X’ button, then bring something else frontmost, it tends not to work after that.
I’ve tried all of click , action ‘AXPress’ and action ‘AXConfirm’, individually and - just for good measure, in combination, but nothing works 100% of the time.
Main question: how can I get Notes to open/display a given note?
Sub question: how can I get System Events to reliably send a textfield’s action?
Academic question: what’s the difference between ‘click’ , action ‘AXPress’ and action ‘AXConfirm’?
ASObjC question: After a while, I thought I’d just Cocoa the **** out of it, but I couldn’t find the ASObjC syntax for creating an NSControl reference in a script and doing a performClick on it, so I gave up on that. Is it possible to do it that way? (Searched both of Shane’s books and the net to no avail).
TIA to any takers of any or all those questions. Here’s a sample of my unreliable code:
set searchString to "change this to some text that will return a hit" tell application "Notes" to launch tell application "System Events" tell application process "Notes" set its frontmost to true set aButton to its text field 1 of UI element 10 of toolbar 1 of item 1 of window 1 tell aButton set its focused to true set its value to searchString #action "AXConfirm" #action "AXPress" click end tell end tell end tell
phil
|