When/where did Applescript Support for Zotero appear?

I have read multiple posts in this Forum advising that Applescript support for Zotero does not exist.

So imagine my surprise when I noticed recently that Script Editor includes a fairly comprehensive Applescript dictionary for Zotero.

Is this a feature of one of the available extensions such as Better BibText?

Was Applescript support added with Zotero 5 and I just never noticed?

Or some other explanation?
  • There's no AppleScript support in Zotero.
  • OK - then why is there a Script Editor dictionary entry for Zotero with all sorts of capabilities listed?
  • What capabilities? As far as I know, most apps will display the standard categories — Standard Suite, Text Suite, Type Definitions. Nothing to do with Zotero itself.
  • Most macOS applications with no scripting capability do not have any Dictionary entry at all. Some with limited capability have only a small subset of "standard" items listed. Zotero has a fairly long dictionary entry for each of those categories.

    Why is there any Applescript entry at all if it is completely unsupported?
  • Zotero is based on Firefox, and it gets the same generic categories with the same generic items as Firefox. I don't know if Mozilla added support for these things specifically or they're just a side effect of the macOS SDK version or build environment, but this is all clearly unrelated to any actual app functionality. I just checked Zotero 4.0 from 2017 and it has the same items.
  • It is still a pity that Applescript is not supported. Sending the currently selected reference from Zotero to any text editor / word processor would be much easier with a bit of scripting. As it stands I seemingly have to script Better BibTeX and use this fly-over window for searching a reference that is already selected in the main Zotero window.
  • We can't support AppleScript for technical reasons, but I also wouldn't put too much stock in the future of AppleScript as an automation technology moving forward.

    For what it's worth, you don't need to use the citation dialog if you want to script this. You could use BBT's debug-bridge to trigger copying/returning of the currently selected item.

    Zotero may offer a local HTTP API in the future that works similarly to the web API.
  • @dstillman Thank you very much for the quick and informative reply. I agree that the future of Applescript looks rather bleak. In the meantime I will check out the mentioned debug-bridge.
  • Untested, but this should get you the selected items (if any) using debug-bridge:

    curl -v -H "Content-Type: application/javascript" --data-binary "const items = Zotero.getActiveZoteroPane().getSelectedItems(); return items.length ? Zotero.QuickCopy.getContentFromItems(items, Zotero.Prefs.get('export.quickCopy.setting'), null, true).text : ''" "http://127.0.0.1:23119/debug-bridge/execute?password=<debug-bridge password>"
  • That's very cool (picking up the selected item via the debug bridge).

    Is there a similar method for uploading a new item via posting something to an appropriate standalone address?

    (The application I have in mind is automating uploading of PDF files into Zotero if they appear in a particular directory - this would allow me to use Devonthink on an ipad as the place where I import documents that will eventually also appear in Zotero). (i.e. meet my requirement at https://forums.zotero.org/discussion/comment/362253#Comment_362253).
  • Ah, ok, I see I should be looking at the thread on python and (local) zotero at https://forums.zotero.org/discussion/comment/363346#Comment_363346, although it seems zotero tablet nirvana is still like Fusion - over the horizon :-)
  • Is there a similar method for uploading a new item via posting something to an appropriate standalone address?
    you can do pretty much anything that Zotero itself can through the debug bridge. So "yes", but you're going to have to get familiar with the Zotero internals to do it.

    WRT to python, almost all of my test suite is in python, the debug bridge just allows my python code to talk to the running Zotero (eg https://github.com/retorquere/zotero-better-bibtex/blob/master/test/features/steps/zotero.py#L151)

    What @dstillman says is entirely true; the debug bridge *is* trivial (just 60 lines of code), on purpose, because any complexity I add there is an avenue for potential bugs of its own which complicates testing, and that's what I originally wrote it for. If it has any use outside that, no problem, but it is mostly just there for my test harness. There isn't so much a "debug interface" as that it's a way to make the Javscript runner available to scripting rather than just posting it into Zotero. As to stable, the last change was 2 years ago to add a password requirement. It doesn't really do much and in that sense it's stable.
  • Thanks. I think at this stage “getting familiar with zotero internals” will be a bridge too far for me personally ... (I’m currently time poor, otherwise I might have been up for it). If and when there is a documented API, then that’d be different ...
  • There is a documented API, the web API. That doesn't require any knowledge of zotero internals, and it's pretty simple to use.
  • Hmm. Thanks. I may be mixing my two use cases here. Indeed, for the "managing my DTP/zotero integration on the Mac" use case, I have the web available. I need to shut up and put more flesh on the use case but for some reason I was thinking I had to have access to my standalone to get access to my files, but Zowie might do enough for that, at least for pre-existing ones. On the mac, I create all zotero content directly in zotero, so that's not a problem, the other use case is the IPAD, but that needs a different solution ... (stop thinking aloud Bryan).
  • Note that Zotero just announced their iPad app beta test
  • Thanks @bwiernlk, I've signed up!
Sign In or Register to comment.