MIDI port issue?

You’re definitely on the wrong trail if you think clicking the mouse is somehow affecting on the midi devices - there no way that could be related. Maybe your drivers can only have one instance of a device open simultaneously, and you’re trying to sometimes open more than one?