I've had some time to test this now. I had two problems:
- The menu would not be clicked for some reason (race condition)?
- The macro would execute twice if triggered by the usb attached condition.
I think I managed to solve both of the issues.
My apple script now looks like this (using Swedish window names etc):
I also added a semaphore to help with the multiple triggers problem. I hope this can help someone else running into these issues.