• 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
AS in TextExpander with user interaction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AS in TextExpander with user interaction


  • Subject: AS in TextExpander with user interaction
  • From: Michael Grant <email@hidden>
  • Date: Sun, 06 Sep 2015 12:25:02 -0500

Anyone here using AppleScript with TextExpander? I'm trying to write an AS snippet that allows the user to insert the contents of an arbitrary text file, but I'm having trouble 1) giving focus to the choose file dialog and then 2) returning focus to the original application for the expansion. What I've got so far works in Script Editor but fails to expand in BBEdit when I call it as a TextEditor snippet — the current application for the script is TextExpander, not the app where I'm actually typing. Any suggestions?

property notesFldr : alias "London:Users:mgrant:Dropbox:SimpleText:"


with timeout of 120 seconds

set ca to current application

tell application "System Events"

activate

set theNote to (choose file of type {"TEXT", "public.plain-text"} with prompt "Choose a note file:" default location notesFldr) as alias

end tell

set theNoteReference to open for access theNote

set theNoteContents to read theNoteReference

close access theNoteReference

tell ca to activate

return theNoteContents

end timeout

--
There's really no such thing as translating. It's all a scam. We basically just make stuff up and try to make it sound plausible.
 _______________________________________________
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: AS in TextExpander with user interaction
      • From: Christopher Stone <email@hidden>
    • Re: AS in TextExpander with user interaction
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: Re: How do we Convert PICT to JPEG
  • Next by Date: Re: AS in TextExpander with user interaction
  • Previous by thread: Re: How do we Convert PICT to JPEG
  • Next by thread: Re: AS in TextExpander with user interaction
  • Index(es):
    • Date
    • Thread