• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scripting the Notes app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting the Notes app


  • Subject: Scripting the Notes app
  • From: 2551phil <email@hidden>
  • Date: Wed, 29 Jun 2016 21:10:16 +0700

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




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scripting the Notes app
      • From: 2551phil <email@hidden>
    • Re: Scripting the Notes app
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: path to script file in script's folder (From: Mitchell L Model <email@hidden>)
 >Re: path to script file in script's folder (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: path to script file in script's folder
  • Next by Date: Re: Scripting the Notes app
  • Previous by thread: Re: path to script file in script's folder
  • Next by thread: Re: Scripting the Notes app
  • Index(es):
    • Date
    • Thread