Alex Watt

About Photos Recommended Books

ESV Text Expander (AutoHotkey)

One of the things I love about Crossway is how accessible they make the ESV text with great tools like ESV.org and the ESV API for developers.

I recently used their API to make a text expander for ESV verses, using AutoHotkey. (Note that AutoHotkey is a Windows-only utility, so if you’re on another OS this won’t be of much use.)

Demo using the script from Microsoft Word.

How it works: I’ve assigned the key combination Windows Key + B (for Bible). Upon pressing that, type a verse or passage reference, and hit tab or enter. The script will grab the text from the API, copy it to the clipboard, and paste it. (It also restores the clipboard to it’s original state when done.)

This is the ESV at the speed of light!

;; ESV Verse Lookup (Windows Key + B for Bible)
;; http://alexcwatt.com/esv-autohotkey
#b::
	Input, ref, V, {enter}{tab}
	If InStr(ErrorLevel, "EndKey:")
	{
		;; API Documentation: http://www.esvapi.org/api
		url := "http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=" . ref
		url := url . "&output-format=plain-text"
		url := url . "&include-passage-references=false"
		url := url . "&include-headings=false"
		url := url . "&include-subheadings=false"
		url := url . "&include-passage-horizontal-lines=0"
		url := url . "&include-heading-horizontal-lines=0"
		url := url . "&line-length=0"
		url := url . "&include-footnotes=false"

		WinHTTP := ComObjCreate("WinHTTP.WinHttpRequest.5.1")
		WinHTTP.Open("GET", url, 0)
		Body = {}
		WinHTTP.Send(Body)

		ClipSaved := ClipboardAll ; backup clipboard
		Clipboard := WinHTTP.ResponseText

		Send ^v

		Sleep 500
		Clipboard := ClipSaved ; restore clipboard
		ClipSaved = ; free memory

	    Return
	}
Return

Posted on 19 Jan 2017.

Never miss an update!


Please note: I reserve the right to delete comments that are off-topic or offensive.

comments powered by Disqus