Jump to content

Automation


Randy Steffens Jr

Recommended Posts

I love the new automation features in the latest Accordance update! I'm wondering if it's possible to create my own automation which would function as follows:

 

Suppose as I type out a sermon that I can remember a substantial phrase of a certain Bible verse, but not the entire thing, nor the reference. So I type the part that I am sure I remember, word for word. I would then like to be able to select that phrase, and trigger an automation which would do a search in Accordance, and then automatically paste back into my document all the hits that were retrieved (which would probably be only 1 or 2 if my phrase was long enough to be sufficiently unique.)

 

This would be like the current "Insert Verses" automation, except with a phrase instead of a verse reference as the search argument.

 

Is anything like this possible with the current implementation?

 

Thanks!

 

Randy

Edited by Randy Steffens Jr
Link to comment
Share on other sites

Randy,

 

Essentially, the answer is yes, and kudos to you for dreaming. You can create a new Service that adds [FUZZY 1] to a search string and have that run in Accordance. Then, you'll have to have a little scripting magic to copy the results in Accordance. I could show you the example. The real problem is that FUZZY searches aren't very reliable. You will often get an error dialog in Accordance saying "no verses in the current range", so in the end, the workflow won't be extremely helpful.

Play with the FUZZY command in Accordance first, and if you think you still want the new workflow that uses it, let me know.

Link to comment
Share on other sites

As I look again, I see the request was to run searches on phrases that you confidently knew word for word.

You can easily create this. (I could provide for you to download, but I think it's great for you to learn to create it.)

 

First, have a look at my instructions on creating a New Service on my blog here.

 

Second, create a Service that has two actions that look like this:

post-16-0-43517100-1404697988_thumb.png

It uses the "View Text in Accordance" Action, because "Get Text…" only works with verse searches. For this Service, you want the top of the workflow option to be "Service receives selected text" (instead of "no input"). I named the action "Acc - Insert From Word Search".

The text of this "Run Applescript" Action ensures Accordance is in the front, tabs into the text result area, selects all, copies the text to the clipboard, and then returns that text back to the Service Workflow for further processing (which in this case will add it to the document where you began. It also hides Accordance, otherwise it will stay in front of your document.

Here is the text of the script for you to paste in:

on run {input, parameters}
	
tell application "Accordance" to activate
delay .4
tell application "System Events"
	tell process "Accordance"
		keystroke tab using {option down} -- select text area
		delay 0.1
		keystroke "a" using {command down} -- select all
		delay 0.1
		keystroke "c" using {command down} -- to copy in citation format add , control down
		keystroke "h" using {command down} -- hide Accordance
	end tell
end tell
delay 0.3
set theResult to the clipboard
delay 0.1
return theResult

end run

This Applescript magic of copying results out of Accordance is necessary for any word search results or any Tool search results. The invisible/behind the scenes getting text from Accordance that you see in the "Get Text from Accordance" Action only works with verses.

Let me know how it goes.

 

Note that there's lots of opportunity for error here. If the search isn't found, it will likely paste in whatever results were already in the front Accordance window. Also, if the results are too large to copy, you'll get an error. You for sure will want to set Accordance Preferences…/Search Tabs/Add context: to "None" as the default for new tabs.

 

And btw, if you DID want to add something to the search string before the "View Text in Accordance" Action, you could add another "Run Applescript" above it, with a script text of:

on run {input, parameters}
	set input to "[FUZZY 1] " & input
	return input
end run
Edited by Joe Weaks
  • Like 1
Link to comment
Share on other sites

Ah this is really clever Joe! Thanks so much! I'll work on creating this.

 

And yes, your second post got my idea spot on. Often a segment of a verse will come to mind as I write, but I don't necessarily know the whole verse perfectly or the reference. So I foresee this script will be of great timesaving value for copying in verses for which I remember a good portion word for word.

 

As an aside, could you recommend any books on learning Applescript? I'd like to get more familiar with it.

 

Thanks!

Randy

  • Like 1
Link to comment
Share on other sites

This works real well! Thanks! The only minor problem is that the applescript line that hides accordance after copying doesn't work because I run Accordance in Full Screen mode.

 

Randy

Link to comment
Share on other sites

I figured it out: Just replace the line:

 

keystroke "h" using {command down} -- hide Accordance

 

To

 

keystroke tab using {command down}

 

Works perfect! Thanks so much!

Link to comment
Share on other sites

Kudos to you for figuring out the tweak to make it work in your situation.

Glad it's working, and glad to help.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...