SW API for Applications COM Port Detection

Hi there,

Does anyone know how to detect a com port action in combination with API for applications ?

For example, I have a device connected with two buttons and would like to put an action under them.

How can I detect one of the buttons is pushed ?​

Greetings !

SolidworksApi macros