Scooter 11 Posted January 7, 2016 Share Posted January 7, 2016 I used to have an applescript that worked well for me. It would create a note and named it based on the date, then place the cursor at the first space and TYPE (not paste, type) a brief word. The reason the typing is important is the word typed was a textexpander trigger word. This has worked great for years but it no longer does. Here is the part that no longer seems to be working. tell application "Evernote" activate tell application "System Events" keystroke return keystroke "..journal " keystroke return keystroke " " end tell end tell This used to call up the front note (created above) go into the note then type keystrokes using System Events. It no longer does that. it still seems to type the letters, but it's somewhere is space, not the note. It does trigger textexpander, but even then it's not in the note so it doesn't matter. Any idea on what has changed and how to fix this? Link to comment
Level 5* JMichaelTX 4,117 Posted January 7, 2016 Level 5* Share Posted January 7, 2016 10 minutes ago, Scooter said: The reason the typing is important is the word typed was a textexpander trigger word. This has worked great for years but it no longer does. Using AppleScript UI events can be unreliable. You might want to take a look at expanding the TE snippet into an AppleScript variable, and then pasting that. See the TextExpander Scripting Dictionary (File > Open Dictionary in Script Editor) Quote expand v : Expand snippet as if its abbreviation had been typed, specify either the snippet or its abbreviation. expand [snippet snippet] : The snippet to expand. [abbreviation text] : The abbreviation to expand. → boolean : Did a snippet expand Link to comment
Scooter 11 Posted January 7, 2016 Author Share Posted January 7, 2016 That's a great idea. I'll experiment with that. Thanks. Link to comment
Level 5* JMichaelTX 4,117 Posted January 8, 2016 Level 5* Share Posted January 8, 2016 53 minutes ago, JMichaelTX said: You might want to take a look at expanding the TE snippet into an AppleScript variable, and then pasting that. Actually, since you are creating a new note, it would be better to just set the Note contents to the TE snippet in the Create Note command. Link to comment
Scooter 11 Posted January 8, 2016 Author Share Posted January 8, 2016 Well, the TE isn't just a string, it's kind of a script with some selections. To work as it used to, I need to actually trigger and use Textexpander. Right now I'm working on running the whole process manually though applescript, then sending the results back to applescript. It's not working yet, and if I do get it working it will be clunky. I wish the old way still worked. It was perfect for a long time. Link to comment
Scooter 11 Posted January 8, 2016 Author Share Posted January 8, 2016 Obviously, I'm not the best scripter in the world. Indeed, I may be the worst! Link to comment
Level 5* JMichaelTX 4,117 Posted January 8, 2016 Level 5* Share Posted January 8, 2016 1 hour ago, Scooter said: I wish the old way still worked. It was perfect for a long time. But it doesn't work now. Could be due to changes in Evernote, TextExpander, and/or Mac OS. This makes it very hard to diagnose and fix. Unless you need to do this many times a day, the best solution now might be to manually type in the TE abbreviation after AppleScript has finished creating the note. As you know the TE abbreviation can be anything you want. So, if it was me, I'd made it ";je" (for journal entry), and be done with it. Typing 3 chars is not a lot of burden. Figuring out the problem with the AppleScript could take many hours. Your choice. Link to comment
Scooter 11 Posted January 8, 2016 Author Share Posted January 8, 2016 Actually, I got it working. A little more awkward than before, but not much. If anybody is interested and has the same stuff I have, here's what I did: I've moved all my scripts over to Keyboard Maestro, then put a "Move mouse and click here" commend from keyboard maestro, then back to the Applescript to run the rest. I did upgrade my script to your TE expansion suggestion (actually, it didn't work as expected, but I added expand abbreviation and it worked). So I'm back up and running. Thanks for the help. Link to comment
Level 5* JMichaelTX 4,117 Posted January 8, 2016 Level 5* Share Posted January 8, 2016 1 hour ago, Scooter said: I've moved all my scripts over to Keyboard Maestro I'm glad to hear you have solved your problem. It would be great if you could post your KM macro either here, or in the KM forum. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.