How to trigger on the attach button when we click it

Hello,
I want to trigger custom code when the attach button got clicked.

How to trigger it when we click on the attach button?

image

This will trigger when the file URL is saved. I want the trigger to occur when the popup appears so that our custom code executes at that time.

Check the form script and set it according to the scenario.