Flying Logic Pro Support

Has anyone tried to support Flying Logic?

It doesn’t have an AppleScript dictionary, so I tried System Events. It seems that the ‘document’ property of the frontmost window of the process, while a value exists, neither ‘name’ or ‘file’ properties are accessible from that property. The best I can do at the moment is get access to the title of the first window, but the address (a la POXIX file path) is still missing.

As I didn’t notice anything already posted here on the topic nor on their forum, I have posted to the Flying Logic forum’s support topic, requesting AppleScript support, including a specific callout re: the necessary Hook functionality. See this post: https://flyinglogic.discoursehosting.net/t/applescript-support/65

I am considering a (likely ugly) hack whereby I store the file in a DEVONthink database, then query DEVONthink for the record (i.e. file) by name I get from the window title. I’d have now way of handling duplicates at the moment, so file naming would have to be unique going into DT.

If anyone has other suggestions for how to work around the current limitation, I’m all ears. (Or would it be “I’m all eyes” considering the medium?)

It’s a Java app, so it doesn’t use the standard set of Apple UI controls.

There is a scripting interface, addressable from Python, for example, but I have a feeling that the document object exposes a title property but not a file path.

And similarly, with System Events, we can get a window title property (which happens to be a file name), but not, as far as I can see, a reference to a document or its filePath:

For example, in Script Editor with the osasacript language selector at top left set to JavaScript:

(() => {
    'use strict';

    Application('Flying Logic Pro').activate();

    const
        procs = Application('System Events')
        .processes.where({
            name: 'JavaAppLauncher'
        });

    return 0 < procs.length ? (
        ws => 0 < ws.length ? (
            ws.at(0).attributes.byName('AXTitle').value()
        ) : 'JavaAppLauncher window not found.'
    )(procs.at(0).windows) : 'JavaAppLauncher process not found.'
})();

A footnote on capturing a file URL to the front document in Flying Logic Pro.

If we create a Python file (.py extension) with the content below:

Python source
'''Path to front document in Flying Logic Pro'''

import urllib


# -------------------------- TEST --------------------------
# main :: IO ()
def main():
    '''Print URL of document'''
    title = document.title
    docPath = document.documentPath
    print(
        '[' + (
            title if title else (
                'No title specified under Document Info'
            )
        ) + (
            '](file://' + (
                urllib.quote(docPath) if docPath else (
                    'Not yet saved'
                )
            )
        ) + ')'
    )


# MAIN ---
if __name__ == '__main__':
    main()

we can open it the first time with Edit > Run Script, in the Flying Logic main menu, and thereafter it will show up in the Edit Run > Script submenu, making it accessible to Keyboard Maestro and presumably to Hook scripts too.

Screenshot 2020-08-06 at 18.55.23

The incantation therein does find and URL-encode the document path, but I haven’t looked into Jython mechanisms for copying the URL to the clipboard.

On my system this Keyboard Maestro macro, which assumes that at docPath.py has been run at least once (containing the Python snippet in the previous post) seems to work.

Might need tweaking (timings etc) for other system. Not sure whether or not this could be implemented as a Hook script:

Screenshot 2020-08-06 at 20.10.30

1 Like

I, too, would like to see a linking solution with Flying Logic. I do not have the RobTrew’s coding skills. If anyone knows of a low-code, no-code approach to linking between Flying Logic nodes and specific documents (e.g. particularly a specific document within an Obsidian Vault), I would love to learn.