This may help you.
The following variables are predefined and will contain the last event: %device%, %value%. %device% will contain the device name that triggered the event and %value% will contain the value, for a button that should be the button number.