Does anybody know if it is possible to have keyboard shortcuts inside a macro?
Lets say you run a macro and when you press "a" it runs "Sub A" and when you press b it runs "Sub B" and if you press "x" the macro ends...
I've used mouse button events in the past so I expected to see something similar for key press events. If similar events exist for keyboard presses, they should show up on this list: 2017 SOLIDWORKS API Help - SolidWorks.Interop.sldworks Namespace
Unfortunately, it doesn't look like Solidworks exposes keyboard events through the API. There are probably workarounds but they may not be as elegant as intercepting events through Solidworks.
You might consider the following approaches:
1. Display a user form and assign hotkeys to particular buttons on that form or implement key press event handlers with the form. I think these would only work as hotkeys while the form has context which might feel sort of clunky from the user's perspective.
2. Work with Windows keyboard events or poll for changes in the keyboard state. I'm not sure how to do this but I would be surprised if there wasn't an example somewhere on the net. Going this route, it would probably be cleaner to build this thing as an add-in rather than a macro - especially if you have to poll for keyboard state.
create usecontrol (with label and exit button). You can catch key press events and it is for user also pretty to know that a macro is (still) running.
Retrieving data ...