did you try:
if ($devent == sclick) echo -a clicked: $did


then take the output of the did and use it in your script. im not sure if it's posible to do this, but you cal always give it a try, or use a dll