Command-line options for starting Logos - specify a particular layout?

Page 1 of 2 (21 items) 1 2 Next >
This post has 20 Replies | 2 Followers

Posts 24
Doug Trick | Forum Activity | Posted: Mon, Sep 30 2013 10:10 AM

Is there any way to specify a "layout" in the command-line when starting Logos4?

The Logos wiki page here indicates, "URIs recognized include the logosref, logosres, and logos4 protocols", and there are helpful examples there for logosref and logosres.  But there are no examples for other "logos4 protocols".  Are others possible?  Specifically, I would like to be able to create a Windows (7) shortcut which would start Logos4 with a specific layout.

Posts 8056
LogosEmployee

Doug Trick:

Is there any way to specify a "layout" in the command-line when starting Logos4?

No, this is not supported, sorry.

(The closest thing would be to write a helper program that uses the COM API to load a specific layout.)

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Mon, Sep 30 2013 2:29 PM

Bradley Grainger (Logos):
(The closest thing would be to write a helper program that uses the COM API to load a specific layout.)

I've never used PowerShell before, so...
(Not sure if this is the correct idiom to wait on object construction, but it seems to work.)

Create a text file. Name it whatever you wish, using an extension of '.ps1' (eg. mylayout.ps1)

Past this code into it:

----------><----------

$launcher = New-Object -com "LogosBibleSoftware.Launcher"
$launcher.LaunchApplication()

do {
        Start-Sleep -s 1
        Write-Host "." -nonewline
} until ($logos = $launcher.Application)

$ret = $logos.LoadLayout("My Layout Name")
Write-Host " Done."

----------><----------

Changing "My Layout Name" to the name of your layout.

You can then create a desktop shortcut in the usual way using the command:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\mylayout.ps1"

Changing the file name & path as appropriate.

EDIT: Modified code to behave a little more responsibly.

Posts 24
Doug Trick | Forum Activity | Replied: Tue, Oct 1 2013 9:16 PM

Thanks so much, Randy.  This looks very promising.  I've never used Powershell before, though, so I need a few more details:

1. When I start the program, I see 3 panes; at the top is a "script" pane, at the bottom is a "command" pane, and I have no idea about the middle pane (documentation?).  Into which pane do I paste the text?

2. For the "My Layout Name" (which I change according to a specific Logos Layout that I've already defined), do I use the double-quotes around the name, or just the parentheses? (At least one of my layouts has a space in it, by the way.)

Doug

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Wed, Oct 2 2013 6:31 AM

Hey Doug,

Doug Trick:
1. When I start the program, I see 3 panes; at the top is a "script" pane, at the bottom is a "command" pane, and I have no idea about the middle pane (documentation?).  Into which pane do I paste the text?

That's the PowerShell ISE (Integrated Shell Environment). You don't need to run that directly. Instead open notepad and copy the script into it; then save it. I'd recommend creating a folder like "C:\Scripts" or "C:\bin" to save it in.

Next create a shortcut on your desktop (right-click on desktop, New->Shortcut) and when it prompts for the location enter:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\mylayout.ps1"

Changing that last past to the name of your script.

Doug Trick:
2. For the "My Layout Name" (which I change according to a specific Logos Layout that I've already defined), do I use the double-quotes around the name, or just the parentheses? (At least one of my layouts has a space in it, by the way.)

PowerShell does need the quotes around the layout name whether there are spaces or not.

Posts 24
Doug Trick | Forum Activity | Replied: Wed, Oct 2 2013 9:15 AM

OK, thanks a million, Randy.  It works great.  I've been looking for something like this for a couple years.  - Doug

Posts 24
Doug Trick | Forum Activity | Replied: Sat, Feb 22 2014 7:14 PM

Hi again!  Just in case you're still watching this post (or if this message will get forwarded to you…)

This method of starting Logos from the command line has stopped working.  Do you have any ideas as to why this might be the case?  I recently upgraded from Logos4 to Logos5.  (I did not purchase a Logos5 system, but just updated/upgraded Logos4 "for free".  The .exe file is called "Logos.exe", file description: Logos Bible Software 5", version 5.2.0.121, date Jan 31, 2014.  This .exe file is in a folder on my hard drive called "…\Logos\Logos4\System\".)

Is it possible that this newer version of Logos does not work with PowerShell?

Doug

Posts 15805
Forum MVP
Keep Smiling 4 Jesus :) | Forum Activity | Replied: Sat, Feb 22 2014 9:57 PM

Doug Trick:
Is it possible that this newer version of Logos does not work with PowerShell?

Logos 5 does not need PowerShell; suggest changing program settings:

Can choose most recent layout OR a named layout.  Personally open to a Blank layout, then choose what to open.

Keep Smiling Smile

Posts 24
Doug Trick | Forum Activity | Replied: Sun, Feb 23 2014 9:56 AM

Yes, thanks for your reply.  I'm aware that it's possible to change layout settings after Logos has started; I have several saved layouts and currently that's what I do.  However, I have several projects in which I need to have 4-5 software programs (Paratext, BART, Toolbox, LOGOS) at the same time, each with a particular layout.  For the other programs, I'm able to specify which layout to use from the command-line, so I can have a script that will open all such programs with the necessary layout.  If there was a way to do so with Logos, that would streamline the process.

For several months, I was using PowerShell to tell Logos which layout to open upon startup (that is, the PowerShell script is called by another script which loads all the programs (and their specified layouts) for a particular project).  Recently PowerShell stopped working, and I'm wondering if that's a consequence of changes to Logos5, or to a recent update of Logos5, or a recent .NET update, etc.  I'm especially interested in the possibility that Logos5 might still work with PowerShell, but maybe the PowerShell syntax needs to be changed slightly due to something new in Logos5.  I'm hoping that maybe Randy would know the answer to that.

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Sun, Feb 23 2014 2:09 PM

Doug Trick:

This method of starting Logos from the command line has stopped working...

Is it possible that this newer version of Logos does not work with PowerShell?

Hi Doug,

I'm afraid I don't have a good answer as far as fixing it. The COM interface does work with all versions of Logos 4 & 5. And PowerShell should still be working. It may be that the object registration for the COM objects in Logos is mixed up. I believe that is what happened on my desktop machine when I installed Verbum side-by-side with Logos (although that's just a guess). It still doesn't work there. The only thing I have tried was running a repair on Logos, but that didn't fix it at the time. However, this seems to have corrected itself with a recent update, possibly, and my clean install on my tablet does still work, so I know that everything should be working.

Maybe Bradley or someone more familiar could chime in with a way to re-register the appropriate components.

EDIT: Re-edited my message after I realized that this is now working on my desktop again. I'm not sure when it self-corrected and still not sure what to advise.

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Sun, Feb 23 2014 2:37 PM

Just to eliminate it, you might want to test PowerShell. Launch the ISE (Integrated Scripting Environment) by:

  1. Pressing the Windows Key + R, to open the Run box.
  2. Type: powershell_ise and press enter.

You can test against Word if you have it by typing the following lines in the ISE, pressing enter as indicated at the end of each line:

$word = New-Object -com Word.Application <enter>
$word.Visible=1 <enter>
$word.Quit() <enter>

Or test against Logos with:

(New-Object -com "LogosBibleSoftware.Launcher").LaunchApplication() <enter>

These should launch the respective application if everything is working or display an error in the ISE if there are problems.

Posts 24
Doug Trick | Forum Activity | Replied: Sun, Feb 23 2014 3:42 PM

Thanks, Randy.  Yes, I can launch PowerShell fine, and when I type in the scripts for MS Word, they work.

When I enter the script for Logos, however, I receive the following message:

(New-Object -com "LogosBibleSoftware.Launcher").LaunchApplication()
Exception calling "LaunchApplication" with "0" argument(s): "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SE
RVERFAULT))"
At line:1 char:66
+ (New-Object -com "LogosBibleSoftware.Launcher").LaunchApplication <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation

Does that sound as though LogosBibleSoftware.Launcher is not properly registered on my system?

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Sun, Feb 23 2014 4:00 PM

Doug Trick:
Does that sound as though LogosBibleSoftware.Launcher is not properly registered on my system?

I believe so. I probably should have suggested running that as two separate command for a better error:

$logos = New-Object -com "LogosBibleSoftware.Launcher"
$logos.LaunchApplication()

It will likely show the error on the first line. I do think the COM registration is possibly broken in some way. When this happened on my system a repair of the Logos application did not correct the problem. You might try downloading and running the installer again from <https://www.logos.com/installation>. If that doesn't work, it may require re-registering the COM components manually. You might have to call in to tech support for that, as I'm not sure of the proper steps to correct that.

Posts 24
Doug Trick | Forum Activity | Replied: Sun, Feb 23 2014 8:52 PM

Thanks another million, Randy.  I did a fresh install using the link you provided, and that seems to have repaired the COM registration, etc, and it's all good now.

Doug

Posts 129
George T. Kelley | Forum Activity | Replied: Tue, Jan 6 2015 10:25 AM

Hi Doug,

Your tip, for running a script to open a particular layout in Logos 5, is great. Do you know of a way to run a powershell script from a macro in Word 2010 & Powerpoint 2010?

When I am using Powerpoint I use one particular layout and in Word a couple of different one, depends wither a sermon or training notes, etc. It would be great if I could run the scripts from a Macro. (I already us macros to open Logos, plus other programs, but it opens Logos to the preset layout in settings.) I have noticed in testing the script that it sometimes opens the last layout and then the scripted one or the default one and then the scripted layout.

God Bless,

Posts 24
Doug Trick | Forum Activity | Replied: Tue, Jan 6 2015 12:45 PM

Hi, George.  Sorry, I wrote some macros for Word97 years ago, but have not tried since then, so I wouldn't know how to do it for newer versions.  Hope you can find someone who knows more about current macro language.

Doug

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Tue, Jan 6 2015 6:00 PM

If you just want to open Logos to a particular layout, you can do it all from within VBA. You could start with something like:

Sub OpenLogos(Optional layout_name As String = "")

Dim launcher As Object
Set launcher = CreateObject("LogosBibleSoftware.Launcher")
launcher.LaunchApplication

System.Cursor = wdCursorWait

' Danger: Loop should have alternatve exit condition, eg. time out
Do: Loop While launcher.Application Is Nothing

If layout_name <> "" Then
   Dim logos As Object
   Set logos = launcher.Application
   logos.LoadLayout layout_name
End If

System.Cursor = wdCursorNormal

End Sub

Posts 129
George T. Kelley | Forum Activity | Replied: Wed, Jan 7 2015 7:58 AM

Thanks for the help.

This works with Word 2010 just find, it launches first loading the default layout and then relaunches it and changes it to the desired layout. However in PowerPoint it launches Logos 5, but does not change to the proper layout, but gives an error. The following is how I used your script (things within [] are my notes; Romans is the Layout name):

Sub OpenLogoSS(Optional layout_name As String = "Romans")

Dim launcher As Object
Set launcher = CreateObject("LogosBibleSoftware.Launcher")
launcher.LaunchApplication                        [this is where it launches Logos in both programs to the default layout]

System.Cursor = wdCursorWait

' Danger: Loop should have alternatve exit condition, eg. time out
Do: Loop Until Not launcher.Application Is Nothing
                                                   [PowerPoint gives a error message here (Run-time error '424": Object Required)]

                                                   [Word relaunches Logos and loads the desired Layout]

If layout_name <> "Romans" Then
   Dim logos As Object
   Set logos = launcher.Application
   logos.LoadLayout layout_name 
End If

System.Cursor = wdCursorNormal

End Sub

God Bless

Posts 2062
Forum MVP
Randy W. Sims | Forum Activity | Replied: Wed, Jan 7 2015 12:37 PM

Trying to do this with phones ringing ever 5 mins, I may have overlooked something more obvious. I'm not hugely familiar with Logos' API as there really isn't much there to play with, but...

This works for me in both Word & Powerpoint. It uses unspecified behavior and the fact that Faithlife doesn't like to acknowledge or display errors in order to open a "blank layout".

Calling LaunchApplication with a nonsensical argument or a blank argument will trick it into ignoring the "At startup open to" setting. However, If the previously running instance of Logos had a layout open, regardless of whether Logos was opened programmatically or by hand, it will open with that layout active but none of resources in that layout open. This could cause you to loose the layout if you were to save it while it was blanked out.

This is fine if you're going to load a layout immediate afterward, but if you just want to open to a blank layout we need a way to close that blanked out layout. To get around it we can call LoadLayout with a non-existing layout name or a blank arguement which closes the layout and then silently ignores the error. We always need to do this in case the layout name we hand off to the sub doesn't exist.

This does have one remaining odd behavior that I haven't figured out. Calling LaunchApplication "" followed by LoadLayout "", opens a blank layout and loads a resource I recently had opened, but not the last resource or the last layout with that resource. I can't make any sense out of the behavior yet. And I don't have a solution.

The code is definitely a kludge and sub-optimal.

Maybe a dev could comment on these behaviors???

Sub testOpenLogos()

  OpenLogos "my layout"

End Sub

Sub OpenLogos(Optional layout As String = "")

System.Cursor = wdCursorWait  'remove for Powerpoint

Dim launcher As Object
Set launcher = CreateObject("LogosBibleSoftware.Launcher")
launcher.LaunchApplication "Bubba"  'non-sensical arg to trick Logos into opening a "blank" layout

' Danger: Loop should have alternatve exit condition, eg. timeout
Do: Loop While launcher.Application Is Nothing

Dim logos As Object
Set logos = launcher.Application
logos.LoadLayout ""  'close any open layout in case the layout name specified does not exist

logos.LoadLayout layout

System.Cursor = wdCursorNormal  'remove for Powerpoint

End Sub

Posts 129
George T. Kelley | Forum Activity | Replied: Thu, Nov 12 2015 9:31 AM

I had given up on using the Macro in PowerPoint 2010, but I canceled out a changefileopendirectory and I went back to having the Error after the Macro ran. After looking at you script and the "System.Cursor = wdCursorNormal 'Remove for PowerPoint" I change it to none active and now I can open all my Bibles with the Macro in PowerPoint. So it is opening Logos6 without error.

Thanks and God Bless,

GeorgeT

Page 1 of 2 (21 items) 1 2 Next > | RSS