Compile without asking questions

I am writing my PhD dissertation in Scrivener (and thank god for that program, I don’t know how I could have done it otherwise!). I have a setup where I mostly just write plain Markdown in Scrivener, with Bibtex citekeys etc. I then compile it as a MMD file, and run a shell script that does some text formatting and then runs Pandoc over it.

This all works very well, but as I am trying to optimize my workflow, I’d love to be able to press a key and get the whole compilation workflow going. I don’t compile often, but occasionally it is encouraging to get a mental idea of how far a chapter has come, seeing it in the “final formatting” is useful for reading through with other eyes, etc.

My ideal solution would be a “Batch compile” menu item, which ran the compile without asking any questions (including overwriting any pre-existing files). Even better if it could also run an optional shell command after the compilation. (If people are worried about this clobbering their existing files without asking, that could be a project-wide setting to enable).

I already use Keyboard Maestro to optimize some workflows within Scrivener, so I tried using it for this. I got it to select the right menu item, and press Compile, but it doesn’t manage to press Export on the file dialog - possibly it doesn’t work in a modal box. I also looked at whether there was an AppleScript “Compile” command, but found that there is no AppleScript support.


For anyone who is interested, it turns out that it is possible to do this with the keyboard (and thus script it through Keyboard Maestro). You need to turn on
“Navigation of all controls on the screen” in the Control Panel -> Keyboard settings, then you can run the sequence Alt-Cmd-E, Space, Enter, Space to run a compile to the default file accepting to overwrite.

If you’d prefer to leave full keyboard access off (personally I like having it on anyway as it really opens up the Mac interface to quick key combinations), you can use Cmd-R to trigger the “Replace” button, instead of Space, as is available with full keyboard access.