This looks a bit … direct, but it dates from 1882. James Williams needed a device that would destroy a burrowing animal and give an alarm so that it could be reset. His solution was a revolver attached to a treadle. Touché.
The patent abstract adds, “This invention may also be used in connection with a door or window, so as to kill any person or thing opening the door or window to which it is attached.” Evidently Williams had bigger problems than rodents.
Current Magazine
via The Futility Closet