MoveNode with exteral button

HI!

i have found a way to add a moveNode with its waypoints thanks to a button present on the screen of the teach pendant.

Now i want to upgrade this feature and be able to add this moveNode thanks to the pressure of an external button.

How can i deal with this topic?

Should i use the XMLRPC to see the change in the button state?
I found some difficulties in being able to read the button state from java, can some one please give me some hints?