Anyone knows how do i draw a border around any window below the mouse cursor?

And also, how do i detect a mouse click and the flags when i clicked the mouse
outside of my application?

thanks