Wait for ChatGPT + copy result

I'm using the ChatGPT mac app to write some code, but copying and pasting from ChatGPT to IDE is getting old* - especially when multiple files are involved.

One solution is to ask ChatGPT to produce a git patch file for all code changes. It's much better but the limitation is that ChatGPT can't create a downloadable link - just the text of the patch file.

I want to:

  1. Send a ChatGPT prompt describing desired changes
  2. Use a KM macro to wait for ChatGPT to finish writing all patch text
  3. Click the Copy button.

I've tried obvious stuff like waiting for a button or an image:
Keyboard Maestro Export

My current ill-advised method involves a loop where I wait a few seconds, click a fixed point, and then check to see if the clipboard changed:
Keyboard Maestro Export

This is not advised, since it clicks specific coordinates that may change depending on multiple factors.

Is there a better way to do this?

What's interesting is that if I scroll up to a previous reply containing a Copy button, then KM will recognize it. Unfortunately it will not recognize a new Copy button.

Finally, note that in the case of producing a patch, only one Copy button is visible after a reply.

*Can you believe the nerve of an AI making me do work? :rofl: