COM API: Help: How do I sent multi-word commands as if typed in the Command Box?

Page 1 of 1 (9 items)
This post has 8 Replies | 0 Followers

Posts 1367
JimTowler | Forum Activity | Posted: Thu, Jul 1 2010 10:52 AM | Locked

(This repeats one of the unresolved questions from Andy and myself from another thread)

Please: How can we send multi-word commands, as if they had been typed in the command box?

Can we send this in some form to Launcher.LaunchApplication("some command here")?

Can we feed it into app.ExecuteUri("logos-cmds:my command goes here") ?

Examples might be:

"Set program scaling to 120"

"Rebuild bible index"

"Update now"

"Set automatic downloads to yes"

"Set update channel to beta"

"Copy john 3:16 from esv to word"

"Open BDAG to page 123"

Posts 4077
Melissa Snyder | Forum Activity | Replied: Thu, Jul 1 2010 11:11 AM | Locked

Inquiries submitted.

Posts 1367
JimTowler | Forum Activity | Replied: Fri, Jul 2 2010 8:21 AM | Locked

Bump.

If the answer to this is really easy and just a few minutes, is it possible to please get some hints on the right usage, before the Long Weekend?

If that's not possible, so be it ... (but it seemed a good idea to ask in case)

Happy 4th by the way.

About all that happens in New Zealand for 4th July, is we get re-runs on the telly of the movie: Independance Day.

Posts 8051
LogosEmployee
Bradley Grainger (Faithlife) | Forum Activity | Replied: Fri, Jul 2 2010 1:02 PM | Locked

JimT:

If that's not possible, so be it ... (but it seemed a good idea to ask in case)

The COM API does not support executing arbitrary commands. (The "command-line arguments" mentioned in the wiki documentation are completely different from the commands supported by the command box in the Logos 4 UI. The only command-line arguments supported are logosref, logosres, and logos4 URIs that can be passed to ExecuteUri.)

Posts 41
Paul Davey | Forum Activity | Replied: Thu, Jul 8 2010 7:22 AM | Locked

If it helps, you can do the last one (I don't have BDAG so I substituted a different resource):

$lg = New-Object -com "LogosBibleSoftware.Launcher"
$lg.LaunchApplication()
$lga = $lg.Application
$chalotcoll = $lga.Library.GetResourcesMatchingQuery("concise hebrew aramaic")
$nr = $lga.CreateNavigationRequest()
$nr.ResourceId = $chalotcoll.Item(0).ResourceID
$nr.reference = $lga.DataTypes.LoadReference("Page.84")
$lga.Navigate($nr)

(This is in PowerShell but of course can be adapted to C# etc). If you know the ResourceID then you can skip the query part. For some reason "CHALOT" does not work.

Posts 1367
JimTowler | Forum Activity | Replied: Fri, Jul 9 2010 2:51 AM | Locked

Paul Davey:
If it helps, you can do the last one ...

Paul,

Thanks for the PowerShell example.

Yes, I knew that example was possible via COM API. I was just running off a list of "random" commands that work from the command box.

I think, unless Logos add the thing we asked here, that I'm going to have to use Bookmarks, and send the Bookmark keypress to the Logos application as a whole.

While this will work for a very limited set of commands, its got major limitations. Including, its a useless way of doing it for an application that others need to use. Its only useful for limited personal use. For others to use it, they of course have to first set up the correct exact command and assign it to the correct Bookmark. Not really very nice, and not at all "hidden" or behind-the-scenes.

I did explore sending <ALT D>Some command sequence goes here<Enter> to the Logos4 application but it does not work well, and it very timing critical. It fails as much as it works, and of course, its also very in-your-face. Not at all nice!

The code below (VB.NET) is something I was messing with about 4-6 weeks ago. It does NOT work well, and it not recommended as is. However, it may be something to continue exploring if someone needs to make something work for their own use. Its NO WAY any good for something that would be used by others. Its "risky" as to what it might do, or if it will work well.

Oh, the "logos4cmd:" part was because at that time, I was attempting to capture that URI type and divert it into the program I was testing per below (registery hack). Bottom line: did not work well. I'm only sharing to help inspire others, and to hint to Logos that unless we can do it with support, we will attempt to make it work some other way. I hate software that "sometimes works", so I like the idea of Logos4 supporting commands sent from the COM API, rather than attempts to send keypresses into the application!

Imports System
Imports System.Windows.Forms

Public Module Module1

    Sub Main()
        Dim keys As String

        'For Each keys In My.Application.CommandLineArgs
        'MsgBox(keys, , "Command Line Parameters")
        'Next

        If My.Application.CommandLineArgs.Count = 1 Then

            AppActivate("Logos Bible Software 4")
            Application.DoEvents()

            Threading.Thread.Sleep(1000) ' Milliseconds

            keys = My.Application.CommandLineArgs(0)
            keys = keys.Replace("%7C", "|")
            keys = keys.Replace("%3C", "<")
            keys = keys.Replace("%3E", ">")
            keys = keys.Replace("logos4cmd:", "")

            'MsgBox(keys)

            'SendKeys.SendWait("%D")
            SendKeys.SendWait("%D" & keys & "~")
            'SendKeys.SendWait("~")
        End If
    End Sub

End Module

Posts 232
AndyTheGreek | Forum Activity | Replied: Tue, Jul 13 2010 3:47 AM | Locked

JimT:
I hate software that "sometimes works", so I like the idea of Logos4 supporting commands sent from the COM API, rather than attempts to send keypresses into the application!

Absolutely.

My current COM API endeavours allow me to open any resource, open and navigate to a headword/bible reference, list what panels are open and track changes to them.

As good as that is, it's hard to think of a real use for such an application other than as a curiosity. If it could send commands to Logos, then scheduling updates becomes possible. If it could set LinkSets between open panels then it would offer a quick way to do something that's a little bit tedious in Logos4.

In short, the API is good and fun to play with, but is rather limited at the moment...

Posts 1367
JimTowler | Forum Activity | Replied: Tue, Jul 13 2010 5:49 AM | Locked

Andy Bell:
In short, the API is good and fun to play with, but is rather limited at the moment...

Agree.

My current view is that it is "ALMOST, but not quite" actually useful for much.

(Douglas Adams would have liked that description I think.)

P.S. If I could write a wish-list (need-list), I would want at least some of:

  • Sending commands to Logos4 ("Update Now" etc, for overnight downloads)
  • Navigation to sub-page level positions
  • Navigation Events reporting sub-page level position
  • Setting of Linking
  • Status report from API Commands (directly, or as a status Event firing), so we know if something worked or was ignored or skipped
  • Ability to send selected UI events (user actions) out the API as Events, so the external application can "pretend" to be an add-on
  • Additional Navigation controls, so the external application can control as if the user had pressed the keys (e.g. Next Highlight or Search Result)
  • Others ..., that escape me at 1 am

If Logos has concerns about giving an external application too much power, I'd be hapy if there was a new setting that had to be enabled before "Commands" would be actioned. I.E. Limit any command that is seen as Powerful or Harmful. E.G. "Import Delete All"

Posts 232
AndyTheGreek | Forum Activity | Replied: Wed, Jul 14 2010 12:00 PM | Locked

One th ng I have managed to do is to use the API to tell a panel containing a Bible to navigate to a different book/chapter/verse. I can also launch things like the Exegetical Guide with it going directly to a verse etc. Things like this do raise the possibility of writing a study program that uses Logos4, especially if there was a way to get the currently selected text for a panel via the API...

Page 1 of 1 (9 items) | RSS