...go ahead and read the manual, we won't tell anyone.

Help Topics > All Functions > Tool

The tool function returns the name of the currently chosen tool. Possible values are the following:browse tool brush tool bucket tool button tool curve tool eraser tool field tool lasso tool line tool oval tool pencil tool polygon tool rectangle tool regular polygon tool round rect tool select tool spray tool text tool

Usage:

the tool
tool()

Example:

if the tool is "field tool" then choose browse tool