We often need to get the offset distance on the screen from a window corner, or a found image corner, to a button or other object we want to click on. This shows you how to get that offset.
You can select a region of the screen by pressing Command–Shift–4 and then holding the left mouse button pressed while dragging the mouse cursor around on the screen. You can see the pixel size of your selection and use it to measure things on the screen as long as you keep the mouse button pressed.
Release the mouse button to take a screenshot. You can dismiss the screenshot/measuring tool by pressing the Escape key.
Screen ruler demonstration video.