When I've finished it, I'll post again with another sample that automatically prints out the state when it changes.