Using AutoHotKey to create customised keyboard shortcuts for Logos

GregW
GregW Member Posts: 300 ✭✭
edited March 6 in English Forum

After the recent video by @Jason Stone (Logos) and Mark Ward I wanted to try to create some keyboard shortcuts to go straight to some of the resources I use most often. I'm a Windows user, so couldn't use Raycast as used by Mark Ward in the short term, so I've done some experimenting with AutoHotkey on Windows 11. I've used AutoKotKey for a number of years as a text expander, but never used it for triggering things like this, so this is all new to me. Autohotkey also has the advantage of being free.

Ref.ly links open up all sorts of possibilities now that they open directly in the desktop app, and some documentation of them would be really helpful. Others far more talented than I am could probably come up with all sorts of creative uses. I've also found that ref.ly links are very forgiving of eccentric Bible reference entries. but it's best to use two-letter entry for books of the Bible in the format Mt2.20 but it doesn't seem to be fazed by spaces.

Essentially, you can create an AutoHotkey script to open anything that's accessible to a ref.ly link. I haven't been able to do it for Factbook as there are a number of complexities in the process of creating Factbook links that I won't go into here.

I've set up a script with shortcuts to open:

  • The Anglicised NIV
  • The ESV
  • NA28
  • BHS
  • Passage Guide
  • Exegetical Guide
  • Text Comparison.

The shortcuts are the strings between to sets of two colons. For example, "oniv" is the shortcut to open the Anglicised NIV and appears in the script as ::oniv::

I've pasted in the script below as my virus checker gets extremely excited if I try to upload or download an AutoHotkey script. My code can probably be made much more efficient as I've repeated the same stuff in multiple shortcuts but I'll do some work to tidy that up in the coming days. I hope this is helpful or sparks some further ideas.

Here's the script: but use it at your own risk, and you'll need to upgrade to AutoHotKey 2 if you're already using it. I have made this my default Autohotkey script starting up with Windows so that any shortcuts I have in it are always available. This isn't supported by Logos, and could collapse in a heap if there are any undocumented changes made to ref.ly.

#Requires AutoHotkey v2.0

/* Open NIV to a reference /
::oniv::
{
/
Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL /
url := "https://ref.ly/" . ref . ";anglniv2011"
Run url
}
/
=============================================================================/
/
Open ESV to a reference /
::oniv::
{
/
Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL /
url := "https://ref.ly/" . ref . ";ESV"
Run url
}
/
=============================================================================/
/
Open NA28 to a reference /
::ona28::
{
/
Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL /
url := "https://ref.ly/" . ref . ";NA28"
Run url
}
/
=============================================================================/
/
Open BHS to a reference /
::obhs::
{
/
Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL /
url := "https://ref.ly/" . ref . ";wivumorph"
Run url
}
/
=============================================================================/
/
Open Passage Guide to a reference /
::opg::
{
/
Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL /
url := "https://ref.ly/logos4/Guide?t=My+Passage+Guide&ref=BibleNIV." . ref
Run url
}
/
=============================================================================/
/
Open Exegetical Guide to a reference */

::oeg::
{
/* Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
url := "https://ref.ly/logos4/Guide?t=My+Exegetical+Guide&ref=BibleNIV." . ref
Run url
}
/
=============================================================================/
/
Open Text Comparison */

::otc::
{
/* Set up an input box to get the reference /
ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
/
Create the ref.ly URL */
url := "https://ref.ly/logos4/TextComparison?ref=BibleNA27." . ref . "&res=anglniv2011%2cnrsv%2cesv%2cnlt"
Run url
}

Tagged:

Comments

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    As an Autohotkey user, I'm interested. For context, @GregW , can you add the link to the interview, please? Thank you!

  • Morgan
    Morgan Member Posts: 503 ✭✭✭

    I had some pretty robust Autohotkey scripts running until for reasons unknown to me the LoadLayout method stopped working. If anyone does some more digging and can get it working on their end I'd love to compare code.

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    @GregW, I finally had some time to play. This is super cool. Thank you!

    I have a few comments.

    1 - I sometimes want to activate one of these things without a place to type. So I think I'll try putting an initial input box that's initiated with a hotkey. Then, from there I can use the input to decide where to take me. I'm pretty new to ahk syntax, but in principle, it should work. Also, I don't know if ahk has a picklist generator or something similar, but that would even be better so I don't have to memorize these combinations.

    2 - Does the comment syntax work for you? Comment blocks

    /* are like

    this. */

    But I'm sure the it's probably correct in your implementation, but the process of pasting into the page here may have introduced some irregularities. I just say this in case someone wants to copy and paste the script. BTW, is your virus checker grumpy about the code, or merely the extension. If I can make any meaningful progress on this, I'll try uploading as a .txt file and see if I can get away with it.

    3 - There are two definitions of ::oniv::

    I think the second one should be something like ::oesv::

    Again, it's probably working for you as expected.

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    Here's a little ahk code that works for me. CTRL + WIN + L activates this. You don't have to remember anything except how to activate it. I like having this from anywhere in Windows. I'm also aware that additions and tweaks of all kinds can be made, but this was just a proof-of-concept for me.

    Just in case anti-virus software blocks the downloading of active code, I've renamed this a txt file.

  • Yasmin Stephen
    Yasmin Stephen Member Posts: 1,729 ✭✭✭

    Thanks for mentioning AutoHotkey; I saw the Mark Ward interview and I went looking for Windows alternatives but didn't come across this one. Raycast has a Windows waitlist that I signed up for.

    I eventually downloaded something called Flow Launcher but it's pretty basic; I can't customize anything (unless I get plugins for it? I'm not sure 🤔). I'll definitely take a look at AHK.

  • GregW
    GregW Member Posts: 300 ✭✭

    you’re quite right. Somehow copying and pasting it here has stripped out all the asterisks and added some extraneous forward slashes, and I put “o NIV” instead of “oesv” for the ESV . There’s probably a single-line comment marker but I always use /* at the beginning and */ at the end which works fine. I’m away at the moment but will post corrected code when I get back home.

  • GregW
    GregW Member Posts: 300 ✭✭

    @Lew Worthington

    You said: “Also, I don't know if ahk has a picklist generator or something similar”

    I have ransacked the documentation to try to find one, but haven’t been able to. That might just be because I’m using the wrong terminology, but I will keep looking!

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    @GregW , actually, the code using an option button I posted works very well. I can use a dropdown list or some kind of array, but I kind of like the looks of this one. I now have this in my Windows startup folder (actually, a link to it) and I've compiled it for use on my other PCs.

    I think the only other two things I'd like to do is start with the top item already selected. You can click or use cursor keys. I'm not sure if I can activate selections using the first letter; i.e., use "B" to select BHS (or hit "N" twice to get to the second item that starts with "N"), etc.

    This app is so helpful, but I'm not sure our discussion is getting a wide enough audience. If you're OK with it, I'll start a new discussion and maybe others can come up with extensions on the concept. I actually obsessed last night with it and configured VS Code to do autocompletion and apply AI to generate tedious code.

  • Morgan
    Morgan Member Posts: 503 ✭✭✭

    @Lew Worthington Any chance you've worked with opening layouts? Previous scripts I've had were able to do so but the LoadLayout command seems to have stopped working for reasons unknown to me.

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    @Morgan , I actually started looking at it, but just for a minute. I saw your stuff earlier that used to work.

    As I said earlier, I'm very new to ahk, and I'm even newer to ref.ly stuff. I can look at it later. One nice thing about using VS Code is that I can pause it and see where it fails in the script. However, I can't see where it fails on the Logos side. I wonder if Logos logs could reveal some info, but I've got no experience there at all.

  • Chris Heil
    Chris Heil Member Posts: 177 ✭✭

    @Lew Worthington , add Send "{Space}" after g.Show in your autohotkey script should get the first radio item selected.

    Windows 11 & macOS 15 (Logos Pro) | iOS 18 (Logos Mobile Beta)

  • Chris Heil
    Chris Heil Member Posts: 177 ✭✭

    I do not think this will work for loading layouts as there is no way to get a ref.ly link to the layout.

    You could do a hack and build a list of all your layouts in the autohotkey script. Your script could then prompt you for the layout you want, send the Alt+D shortcut to Logos to open the Command Box, and then send the Open [layout name chosen] to open your layout. Logos would have to be running and the list of layouts in the script would have to be updated manually. Not very elegant.

    Windows 11 & macOS 15 (Logos Pro) | iOS 18 (Logos Mobile Beta)

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    Thanks for the reply, @Chris Heil. I was looking for doing it as an option. I just didn't know the syntax at the time. It's analogous to other languages. We can just replace

    g.AddRadio 'w500 vrad', 'NA28'

    with

    g.AddRadio 'w500 vrad Checked', 'NA28'

    using the "Checked" option.

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    I also thought the same thing, but Morgan said it used to work for him. I'm not really sure how I would use such a feature, but I thought the challenge was interesting. I wonder if there's some undocumented startup parameter we can pass.

  • Lew Worthington
    Lew Worthington Member Posts: 1,639 ✭✭✭

    It looks like there's a way to use a com object to load a layout. So there's no need to get a ref.ly link.

    Apparently, that's what @Morgan was referring to. (BTW, Morgan, your code is not present in the links you sent.)

    However, someone else had also noticed a change in behavior unrelated to Logos. https://www.autohotkey.com/boards/viewtopic.php?style=19&t=122575

    It's the same kind of error I'm getting, and I haven't really looked into it.

  • Morgan
    Morgan Member Posts: 503 ✭✭✭

    Lol, that's me as well.

    It was a way to create dynamic layouts with Workflows. Complicated to explain but I think it was working similar to Accordance workspaces.

    Here's a simple example using the COM API. Just replace "Layout" with one you have, quotes included.

    Enabled := ComObjError(0)

    ^Numpad1::
    Logos := ComObjActive("LogosBibleSoftware.Application")
    Logos.LoadLayout("LAYOUT")
    return

  • Morgan
    Morgan Member Posts: 503 ✭✭✭

    Here's a script for running searches that I still use for quick bible searches that recognizes quotation marks for precise searching, which I remember took me a bit to figure out. Still using an L4 link.

    ^'::

    InputBox, a

    b := StrReplace(a, """" , "$22")

    Run, logos4:Search

    return

  • Morgan
    Morgan Member Posts: 503 ✭✭✭

    Weird, copy and paste didn't work for the Run line and it won't let me edit. Should be
    Run, logos4:Search;kind=BibleSearch;q=%b%;syntax=v2;documentlevel=verse;match=stem;in=raw:Top$7CDataType$3Dbible$7CResourceType$3Dtext.monograph.bible$7CResultLimit$3D5$7CTitle$3DTop$2520Bibles;viewkind=passages

  • GregW
    GregW Member Posts: 300 ✭✭
    edited March 11

    Apologies for miscopying in original post. The Forum software seems to strip out asterisks in random places so I've replaced the section comment markers with line comment markers (;). Here is my script again, also corrected for the function to open the ESV.

    #Requires AutoHotkey v2.0

    ; Open NIV to a reference
    ::oniv::
    {

    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/" . ref . ";anglniv2011"
    Run url
    }
    ; =============================================================================
    ; Open ESV to a reference
    ::oesv::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/" . ref . ";ESV"
    Run url
    }
    ; =============================================================================
    ; Open NA28 to a reference
    ::ona28::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/" . ref . ";NA28"
    Run url
    }
    ; =============================================================================
    ; Open BHS to a reference
    ::obhs::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/" . ref . ";wivumorph"
    Run url
    }
    ; =============================================================================
    ; Open Passage Guide to a reference
    ::opg::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/logos4/Guide?t=My+Passage+Guide&ref=BibleNIV." . ref
    Run url
    }
    ; =============================================================================
    ; Open Exegetical Guide to a reference

    ::oeg::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    url := "https://ref.ly/logos4/Guide?t=My+Exegetical+Guide&ref=BibleNIV." . ref
    Run url
    }
    ; =============================================================================
    ; Open Text Comparison

    ::otc::
    {
    ; Set up an input box to get the reference
    ref := InputBox("Enter Bible Reference", "Reference",, "ref").value
    ; Create the ref.ly URL
    url := "https://ref.ly/logos4/TextComparison?ref=BibleNA27." . ref . "&res=anglniv2011%2cnrsv%2cesv%2cnlt"
    Run url
    }