How to detect LMB clicks?
Create a Modal operator and set your code to run on event.type='LEFTMOUSE'.

You can search for it on google or read this forum answers https://blenderartists.org/t/trigger-action-through-mouseclick/674367