Minecraft – How to reset a command block’s status

minecraft-java-editionminecraft-redstone

I'd like to use a comparator to act when e.g. a testforblock command block attached to a button triggers. But the comparator changes its state only when the button is pressed after the test result changes, while I'd like to have a short pulse if nothing changed, i.e.

previous command block state | new command block state | desired output
           on                |           off           |      off
           off               |           on            |      on
           on                |           on            |      briefly off, then on
           off               |           off           |      briefly on, then off

How can this be achieved?

Best Answer

Try this contraption:

Please accept this answer if you want to.

It will work exactly as you described.