How to catch the cursor finish event?

I want to capture it and send my own notification, such as a Discord webhook. Prompt injection might work, but I’m afraid it could impair the AI’s effectiveness because I’d be asking it to do unnecessary tasks.