Jump to content

Paste into any app without opening Accordance


wayne@dubbo.org

Recommended Posts

Accordance has a service where you can paste Bible verses into any app. I've written an improved version that suits me when I'm writing talks and need to paste in lots of references. 

 

Here's what it looks like:

pasteverses.jpg

 
Once it's installed you simply:
 
1. Press Apple-7 from any application.
2. Type the verse you want.
3. It will paste the verse from accordance into that app.
 
You can download it from here:

https://macintoshhowto.com/productivity/paste-verses-from-accordance-without-leaving-your-word-processor.html

 

Feel free to use it, change it, etc. There's a 'Quick Action' version that you can use, or if you are a programmer there's an AppleScript version that you can customise.

 

It's a bit like the built in services in Accordance except (1) it brings up a dialog asking for the verse that you need and (2) It remembers the last verse that you typed.
 
I'm happy for any feedback. wayne@dubbo.org

post-279-0-34229800-1539205102_thumb.jpg

Edited by wayne@dubbo.org
  • Like 6
Link to comment
Share on other sites

Wayne,

 

I just wanted to say don't get discouraged at no responses. For over a decade I've been putting scripts out there for Accordance users (such as this post over a decade ago) and sometimes you feel on an island. Those were a library of scripts for Quicksilver, Launchbar, Butler, and eventually part of the Automator Workflows they have now.

 

Keep fighting the good [automated] fight.

  • Like 1
Link to comment
Share on other sites

Wayne,

 

Is there a way to change the translation? I have downloaded "other versions" but I actually use the CSB 17. Did not know if there is an easy way to change the translation.

 

Bob

Link to comment
Share on other sites

Is there a maximum number of verses?

Link to comment
Share on other sites

Is there a way to change the translation?

 

After you install the Service, you can open the file in "/Library/Services/" with the Automator.app and then find the 9th line that says:

set theModulename to "NIV"

and change it to 

set theModulename to "CSB"

or whatever.

Link to comment
Share on other sites

This gets me thinking... at least several times a week, I find myself looking at a verse and wanting to know "how is this specific verse rendered in all other translations I have access to". This question almost always pops up when I am not at my computer. (i.e. Today I was reading a commentary and wanted to see how all translations handle the variant in John 3:13) Sadly this cannot be done on iPhone/iPad. It is possible spend 10 minutes or so flicking through each translation one by one copying out the text of each verse into notepad or something, but that is quite time consuming!

 

You are making me think that this type of thing could be automated, i.e. perhaps I could probably set up something where I "email my computer at home with subject line 'LOOKUP John 3:13'", and then "my computer picks up the email", "pulls the verses", and "emails the verses back" Maybe its time I finally learn the mac automation tools. (I usually only do command line stuff)

Edited by Ιακοβ
Link to comment
Share on other sites

…perhaps I could probably set up something where I "email my computer at home with subject line 'LOOKUP John 3:13'", and then "my computer picks up the email", "pulls the verses", and "emails the verses back"…

 

The short answer is, yes, you can do that using the normal Mail.app trigger rules with a perform action: Run Applescript.

  • Like 2
Link to comment
Share on other sites

The short answer is, yes, you can do that using the normal Mail.app trigger rules with a perform action: Run Applescript.

 

Thanks! Learning AppleScript will have to go on my list of things to do after my thesis is submitted.  

Link to comment
Share on other sites

This is great! Thank you! I'm a big fan of automation and love how Accordance works so smoothly with AppleScript and Services! 

Link to comment
Share on other sites

My density level must be high! I have installed and I have assigned the shortcut and it works BUT I have been unable to modify the file to have the CSB as the text. I opened automator but cannot find the "workflow" or whatever it is called in order to modify line 9. Any help would be greatly appreciated. Sorry.

 

Bob

Link to comment
Share on other sites

Bob, files for Services are located at:

~/Library/Services/

 

If you go to "Finder", click the "Go" menu, then press the "Option" key and the normally-hidden "Library" folder will be revealed. Click it to open that folder and then find the "Services" folder inside it.

Link to comment
Share on other sites

Joe,

 

Thanks for the reply. I actually had trouble determining which service it was.

 

Bob

Link to comment
Share on other sites

Sadly it doesn't work for me.  I have tried altering the script a few times to fix it, to one of the following:

 

tell application "System Events" to tell (1st process whose frontmost is true) to keystroke "v" using {shift down, option down, command down}

 
tell application "System Events" to tell (1st process whose frontmost is true) to keystroke "v" using command down
 
tell application "System Events" to keystroke "v" using {command down}
Edited by Ιακοβ
Link to comment
Share on other sites

To be clear, when I say "It doesn't work" what I mean is, the thing runs, but then it doesn't do the last step (paste). I have to then do a manual paste to get the last step to work. But apart from that, it's great.

Link to comment
Share on other sites

I downloaded the script for Keyboard Maestro. It works great!

I usually copy from only one version.

The benefit is that once the source version is set up, I don't have to choose it every time.

If I need another version, I can use the official Get Verse service.

Link to comment
Share on other sites

In case anyone is interested, I've made a few adjustments to the script, allowing run-time selection of text and citation style. As, Martin just mentioned above, you can use the built in Get Verses service, if you have Accordance open, to select module and reference. With the adjustments below you need not have Accordance open to have access to the same options.

# Applescript to paste verses from Accordance into the frontmost application
# by Wayne Connor - https://macintoshhowto.coma
# 
# You can access this from any app (Word, Pages, mail etc)
# Press Apple-7, type the verse you want, and it will be pasted into you app.
#

# There are a few options on how to access this script easily 
# 1. Assign it to a kotkey (I use Command - 7) usign Keyboard Maestro
# 2. Use the automator workflow Quick Action and assign it to Command 7 hotkey using
#    System Preferences: Keyboard: Shortcuts: Services 
#     and assign a shortcut key to  Paste Bible Verses
# 3. Use it as a Moicrosoft Word add-on
#

set theModulename to ""
set theVerseref to ""
set theCitationformat to ""

try
	tell application "Finder"
		set textList to name of files of folder ((path to home folder as text) & "Library:Application Support:Accordance:Modules:Texts:")
	end tell
	
	set sortedList to simple_sort(textList)
	choose from list sortedList with prompt "What text would you like?"
	if the result is not false then
		set theModulename to item 1 of the result
		set theModulename to remove_extension(theModulename)
	end if
	
	if theModulename is "" then
		error
	end if
	
	tell application "System Events"
		set refResult to display dialog "Verse Reference (eg John 1:1)" default answer theVerseref buttons {"Cancel", "Without Citation Format", "With Citation Format"} with icon path to resource "application.icns" in bundle (path to application "Accordance")
	end tell
	
	set theVerseref to text returned of refResult
	
	if button returned of refResult is "With Citation Format" then
		set theCitationformat to "true"
	end if
	if button returned of refResult is "Without Citiation Format" then
		set theCitationformat to "false"
	end if
	
	
	if theVerseref is not "" then
		tell application "Accordance" to set theText to «event AccdTxRf» {theModulename, theVerseref, theCitationformat}
	else
		set theText to ""
	end if
	
	if text 1 thru 3 of theText is "Err" then
		display dialog "Sorry I don't recognise that verse format. 
Please use format your verse like this: 
John 3
John 3-5
John 3:16
John 3:16-18
1 John 2
" & theText with icon caution
		set theText to ""
	end if
	
	set the clipboard to theText
	
	activate application (path to frontmost application as text)
	tell application "System Events" to tell (1st process whose frontmost is true) to keystroke "v" using {shift down, option down, command down}
	
	
end try

on simple_sort(my_list)
	set the index_list to {}
	set the sorted_list to {}
	repeat (the number of items in my_list) times
		set the low_item to ""
		repeat with i from 1 to (number of items in my_list)
			if i is not in the index_list then
				set this_item to item i of my_list as text
				if the low_item is "" then
					set the low_item to this_item
					set the low_item_index to i
				else if this_item comes before the low_item then
					set the low_item to this_item
					set the low_item_index to i
				end if
			end if
		end repeat
		set the end of sorted_list to the low_item
		set the end of the index_list to the low_item_index
	end repeat
	return the sorted_list
end simple_sort

on remove_extension(this_name)
	if this_name contains "." then
		set this_name to ¬
			(the reverse of every character of this_name) as string
		set x to the offset of "." in this_name
		set this_name to (text (x + 1) thru -1 of this_name)
		set this_name to (the reverse of every character of this_name) as string
	end if
	return this_name
end remove_extension

This will give you an alphabetically sorted list of all text modules in your library and then give you the option to use citation formatting or not.

 

Caveats: 1) I did this to learn some AppleScript. I make no claim to have any expertise. 2) there is a slight delay if you have a large library as AS doesn't have a built in sort function and this one above is slow. 3) Regarding two, I don't think there is an Acc event that one can query about library items, but if so, that would be much faster. 4) AS gives no control over dialog sizes, so with a large library the window is… long. And finally 5) why would you ever not have Accordance open so as to have to lower your standards to this (a claim made only about my additions, the original is slick and efficient, and I thank Wayne greatly for his time in programming and heart in sharing).

Edited by Graham Buck
  • Like 1
Link to comment
Share on other sites

In case anyone is interested, I've made a few adjustments to the script, allowing run-time selection of text and citation style. ...

 

This is really neat. Thank you for your work on it! Would there be any way to select multiple texts so as to do a translation comparison?

Link to comment
Share on other sites

This is really neat. Thank you for your work on it! Would there be any way to select multiple texts so as to do a translation comparison?

 

Considering what Joe said before about the mail AppleScript trigger, I'm trying to figure that out. I think it'd be neat to grab the contents of a text browser. I would require Acc to be open to snag the contents of the browser. AccdTxRf doesn't work on multiple resources.

Edited by Graham Buck
  • Like 1
Link to comment
Share on other sites

In response to above: https://www.accordancebible.com/forums/topic/24727-paste-into-any-app-without-opening-accordance/?p=121647

 

Ok, here's what I've got:

-- Set variables
set theTexts to {}
set theResults to {}

-- Get information from Mail
tell application "Mail"
	set theQuery to (first message of inbox whose read status is false and subject contains "LOOKUP")
	set theSubject to subject of theQuery
	set theAddress to sender of theQuery
end tell

-- Parse the Subject
-- Turn subject into a list
set text item delimiters to "*"
set theItems to (every text item in theSubject) as list
-- Get the reference
set text item delimiters to "; "
set theRefs to (every text item in item 2 of theItems) as list
-- Get the translations you want
set text item delimiters to ", "
set theTexts to (every text item in item 3 of theItems) as list


-- Get data from Accordance
repeat with theReference in theRefs
	repeat with theModulename in theTexts
		tell application "Accordance Aleph" to set theText to «event AccdTxRf» {theModulename, theReference, "true"}
		copy theText & "\n" to the end of theResults
	end repeat
end repeat

-- Concatenate result list into a single string
set theResultsText to ""
repeat with theTrans in theResults
	set theResultsText to theResultsText & theTrans
end repeat

-- Generate reply email
tell application "Mail"
	set theMessage to make new outgoing message with properties {subject:"RESULTS of " & theRefs, content:theResultsText}
	tell theMessage
		make new to recipient with properties {address:theAddress}
		send
	end tell
	tell theQuery
		set deleted status to 1
	end tell
end tell

Just save the script to ~/Library/Application Scripts/com.apple.mail and set up a rule in Mail.

 

post-30445-0-58782200-1540069045_thumb.png

 

You create an email with these items in the subject, separated by an asterisk '*'

1. LOOKUP - the key word

2. the verse reference, or references you desire, separated by a semicolon

3. the translations you want search, delimited by a comma

 

So, for example: LOOKUP*Gen 2.2-4; Rev 5.1-3*NIV11-GKE, NRSVS, NLT-SE, NET

 

And you'll get a reply email with the selected verses in the selected translations.

 

Let me know how it works for you.

 

I can look into modifying for work on your machine with a keystroke some time later.

Edited by Graham Buck
  • Like 2
Link to comment
Share on other sites

Would there be any way to select multiple texts so as to do a translation comparison?

 

This is a good idea, so I wrote a script routine that takes a verse reference and returns the text in every relevant module version you have installed in Accordance. I posted it in a separate topic.

Link to comment
Share on other sites

To be clear, when I say "It doesn't work" what I mean is, the thing runs, but then it doesn't do the last step (paste). I have to then do a manual paste to get the last step to work. But apart from that, it's great.

 

strange.

 

if you run it from 'script editor' is there  an 'error message' in the log window?

Link to comment
Share on other sites

In case anyone is interested, I've made a few adjustments to the script, allowing run-time selection of text and citation style. As, Martin just mentioned above, you can use the built in Get Verses service, if you have Accordance open, to select module and reference. With the adjustments below you need not have Accordance open to have access to the same options.

 

I'm getting this error below.

It seems my accordance files are in /Library not ~/Library.

Is that normal?

 

tell application "Finder"

path to home folder as text

--> "Macintosh HD:Users:macbook:"

get name of every file of folder "Macintosh HD:Users:macbook:Library:Application Support:Accordance:Modules:Texts:"

 

--> error number -1728 from folder "Macintosh HD:Users:macbook:Library:Application Support:Accordance:Modules:Texts:"

end tell

Link to comment
Share on other sites

Joe,

 

Thanks for the reply. I actually had trouble determining which service it was.

 

Bob

Is it working now for CSB?

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...