Jump to content


Photo

Automation


  • Please log in to reply
5 replies to this topic

#1 Randy Steffens Jr

Randy Steffens Jr

    Silver

  • Active Members
  • PipPipPip
  • 166 posts
  • Accordance Version:10.x

Posted 06 July 2014 - 11:03 AM

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, 06 July 2014 - 11:16 AM.


#2 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,025 posts
  • Gender:Male
  • Location:Raytown, MO (outside KC)
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:8.x

Posted 06 July 2014 - 06:40 PM

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.


Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#3 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,025 posts
  • Gender:Male
  • Location:Raytown, MO (outside KC)
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:8.x

Posted 06 July 2014 - 09:07 PM

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:

Attached File  Screen Shot 2014-07-06 at 8.32.18 PM.png   143.67KB   0 downloads

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, 06 July 2014 - 09:37 PM.

  • danieleburrow likes this
Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#4 Randy Steffens Jr

Randy Steffens Jr

    Silver

  • Active Members
  • PipPipPip
  • 166 posts
  • Accordance Version:10.x

Posted 06 July 2014 - 11:01 PM

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


  • danieleburrow likes this

#5 Randy Steffens Jr

Randy Steffens Jr

    Silver

  • Active Members
  • PipPipPip
  • 166 posts
  • Accordance Version:10.x

Posted Yesterday, 04:40 AM

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



#6 Randy Steffens Jr

Randy Steffens Jr

    Silver

  • Active Members
  • PipPipPip
  • 166 posts
  • Accordance Version:10.x

Posted Today, 09:48 AM

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!






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users