Indeed, the g31 gcode command causes a probing operation (unless you are using a CSMIO controller which has its own version plus an odd gotcha). Cnczone has plenty of examples if you can wade through a lot of dross to find them. I wrote my own height probing macros based on what I found there; I would be happy to post them but I have modified them to work with a CSMIO so they are not useful for non-CSMIO machines as they stand. I have three in the set - simple tool-height set, set tool height and then touch off fixed plate, touch off fixed plate for second-tool operation. I also have a tweaked first-page of the standard screenset to assign these to buttons.

Or you could contact Gerry/ger21 and buy his reasonably-priced and well-regarded 2010 screenset which has all these functions and more already built in. I wrote my own because I wanted an excuse to play with a bit of macro coding and screenset tweaking, not because they are any better.