HowTo open a Layout with a Link (Tip)

Page 1 of 1 (8 items)
This post has 7 Replies | 2 Followers

Posts 329
PJ | Forum Activity | Posted: Sat, Jul 27 2019 7:07 AM

It's not possible to use the logos4 protocol to open a layout. I made a small AutoHotkey script to acomplish just this.

How it works

By renaming the Logos.exe file in %UserProfile%\AppData\Local\Logos\Logos.exe to Logos8.exe I can now compile a small ahk executable and name it logos.exe and put it in the same directory.

This small file handles the logos4 protocol and if it finds my new "layout" command it opens the Layout else it forwards to logos8.exe where it was originally intended to go.

In Logos I can now use my custom link, logos4:layout|Bible and Commentary

This script can only handle spaces and the pipe char as I don't need any extra functionality. I just thought to share this trick as I saw a lot of users strugling with this restriction.

The possibilities of what you can do next with this sample is actually awesome. But, I leave this creative expidition to you ...

Source Code (AutoHotKey)

#SingleInstance Force
#Persistent
#NoEnv

HayStack = %1%
Needle := "layout"

If InStr(HayStack, Needle)
{
        arr := StrSplit(HayStack,"%7C")
	inputstr := arr[2]
	StringReplace, output,inputstr,`%20,%A_Space%,All
	comobj := ComObjActive("LogosBibleSoftware.Application")
	comobj.LoadLayout(output)
}
Else
   run, %A_ScriptDir%\Logos8.exe ,"%1%"

ExitApp
Posts 4602
Forum MVP
Fred Chapman | Forum Activity | Replied: Sun, Jul 28 2019 12:26 PM

I'm not a techie, but if I understand your post, this hotkey script opens Logos to a specific saved layout. Is that correct?

If my understanding is correct, how does that differ from setting Logos to open a specific layout in Program Settings?

Posts 329
PJ | Forum Activity | Replied: Sun, Jul 28 2019 12:43 PM

Fred Chapman:
this hotkey script opens Logos to a specific saved layout. Is that correct?

Yes, this is correct.

Fred Chapman:
how does that differ from setting Logos to open a specific layout in Program Settings?

With some extra coding you can link a Layout of your choice from anywhere in Logos where you can insert a link. You can capture the headword or reference of any open panel and pass it on to the new Layout's Resource, Guide or Tool of your choice.

Let's say you are working in a Workflow. When you click on a link it can open a new Layout, using your code, and pass the Reference you are working to another Workflow.

This isn't the savest way to do this, there are another option but requires a running script and a lot more code. I think that FaithLife should look into this discovery as it can be a security threat. Links from the Software should not be able to pass anything other than acceptable information via the protocol.

Posts 2820
Doc B | Forum Activity | Replied: Sun, Jul 28 2019 3:14 PM

PJ:
it can be a security threat

If I understand your explanation, it can only be a threat for those who rename their app. No?

My thanks to the various MVPs. Without them Logos would have died early. They were the only real help available.

Faithlife Corp. owes the MVPs free resources for life.

Posts 329
PJ | Forum Activity | Replied: Sun, Jul 28 2019 9:59 PM

Doc B:
it can only be a threat for those who rename their app. No?

Maybe I read to much on how trojans sneak into systems. I asked Faithlife to look into this. I don't think any software should allow this kind of scripting to fool it and doesn't feel comfortable that this is even possible. The weakness is that there is no verification between the application and the registry to verify that something changed. I don't feel comfortable to give more technical information on this. I would love to be wrong, but from how I look at it, it should be a concern.

Posts 8012
LogosEmployee

PJ:
I think that FaithLife should look into this discovery as it can be a security threat.

PJ:

Maybe I read to much on how trojans sneak into systems.

If this were a problem in the default installation of Logos 8, we would investigate it.

If there's already malware on the system changing the registry, then the computer is compromised and there's nothing we could do to mitigate that. (Advanced malware could circumvent our "verification between the application and the registry" to fool Logos into thinking the registry wasn't changed.)

A Microsoft developer has a post about a similar situation: https://devblogs.microsoft.com/oldnewthing/20190109-00/?p=100665 

Posts 329
PJ | Forum Activity | Replied: Mon, Jul 29 2019 9:04 PM

Bradley Grainger (Faithlife):
A Microsoft developer has a post about a similar situation: https://devblogs.microsoft.com/oldnewthing/20190109-00/?p=100665 

I intercepted the humor behind this Bradley. I appreciate the clear well defined answer. I'll try to give more "selfsafe" solutions to problems.

Posts 329
PJ | Forum Activity | Replied: Mon, Jul 29 2019 10:52 PM

I officially abandon the above approach. The following is then the better, saver solution.

  • Give the script a filename corresponding to the layout you want to open.
  • Add the Script as a Button on the Shortcuts bar
  • The Script Takes the Active Panel's reference and transfer it to the new Layout's Active Panel
  • This will work for Bibles (Tested only against Bibles)

I didn't check this code under all possible configurations. It should work if Source and Destination Panels take the same Reference. There are obviously room for improvement, but this should give those struggling with initializing layouts to a reference a start. This code can easily be ported to another scripting language. If you do so, please add it for others that want to make use of it.

CODE

#SingleInstance Force
#NoEnv
 
;Copy and Paste the Code to NotePad or Prefered Editor for AHK
;Save the File with the Name of the Layout You Want To Open
;Example: My New Layout.ahk
;Add the Script as a Button to the Shortcuts bar

;=============================================================
; Only need to fix bugs if any popup
; The code will open the layout using it's FileName
;=============================================================
;Check if it's a compiled script
If (Instr (A_ScriptName,.exe)==True)
{
	;Capture the Filename to be used as Layout removing the extention .exe
	StringReplace, layout,  A_ScriptName, .exe, ,All		
} else {
	;Capture the Filename to be used as Layout removing the extention .ahk
	StringReplace, layout,  A_ScriptName, .ahk, ,All		 
}

;Attach the Script to the running Software Instance
Logos := ComObjActive("LogosBibleSoftware.Application")		

;Get the Active Panel
ActivePanel := Logos.GetActivePanel				
;Get the first Headword Entry
Ref := ActivePanel.GetCurrentReferencesAndHeadwords.Item[0]	
;Create a Navigation Request
NavigationRequest := Logos.CreateNavigationRequest			
;Set the Navigation Request to the reference of the ActivePanel
NavigationRequest.Reference := Ref.Reference				

;Load the layout
Logos.LoadLayout(layout)									

;Get the ActivePanel in the Destination Layout
DestinationPanel := Logos.GetActivePanel	
;Request the Panel to Navigate to the Reference
DestinationPanel.Navigate(NavigationRequest)				

;The Script will now exit
Page 1 of 1 (8 items) | RSS