Keyboard Maestro can trigger a macro when a USB Device is attached or detached.
A great use for this trigger is to launch your scanner software when you turn on your scanner, and quit it when you turn off your scanner.