Yes, this is a tricky bit of timing. What you could do is this:
Code: ags
function on_mouse_click () {
if (button == LEFT) {
ProcessClick ();
runmycode = 1;
}
}
function repeatedly_execute () {
if (runmycode) {
MyCode ();
runmycode = 0;
}
}