Emacs-lisp hooks for detecting change of active buffer?

I am trying to execute when the active buffer has changed by either Changing the buffer in the current window (e.g. C-x <left>). Switching to another window (C-x o). Switching to another fra...