I wondered which is the best way to interconnect black boxes between each other?

e.g. autodetect mouse on the first black box and if a left click button is pressed, start drawing a line. Autodetect the second black box and if a left click button is detected then connect the two black boxes with each other. Continue till the user stop the interconnection process.

Thanks.

James