The way that I would approach the task would be:
Start Audacity recording:
Record “Access Granted” … (space)
Record “Access Denied”… (space)
Record …
Stop the recording.
Audacity is designed to work as a GUI application, though there is some experimental support for scripting.
As you require full automation with comprehensive command line support you would probably do better to use SoX http://sox.sourceforge.net/
Audacity can be made to do this but it would take a lot of programming work. I suspect that (if not SoX) a VB/VC++ app, from scratch, might be easier to write than hacking the Audacity code. If you want to hack the Audacity code, most of what you need can be found here: https://forum.audacityteam.org/t/unattended-command-line-processing/15543/10
where I have made code available which allow this kind of operation.