Working with more than one track at a time is tricky with Nyquist. Where mono tracks are used it is easier to join them into one stereo track before processing, then split the stereo track back to two mono tracks after processing (the code here may then be useful: https://forum.audacityteam.org/t/ez-patch/22093/1)
Thanks for the advice. Given that it is difficult to work with multiple tracks (and assuming clicks can be accurately detected), would it be possible to instead log the location and duration of the clicks to a file. Then use this log file to mute the clicks in one track, and mute everything but the clicks in the other?
You could analyze the fault track and in one pass detect the clicks, write a text file with start/end times for each correction, and mute those parts. Then run a plug-in that reads the text file and mutes everything except for those parts.
Alternatively (and possibly easier to program) you could write a WAV file to disk that has amplitude 0 where you want to mute the track and amplitude 1.0 where you want the track not muted. Example: to mute from 0.0 to 3.0 seconds and from 3.5 seconds to the end of the selected track, leaving 3.0 to 3.5 seconds not muted:
; find the end of the selection
(setq dur (get-duration 1))
;; "controlwave" is the waveform that would be written to disk
(pwlv 0 3.0 0 3.0 1 3.5 1 3.5 0 dur 0)))
;; Applying the controlwave to the selected audio
(mult controlwave s)