Switch between multiple displays (monitors) directly with a shortcut or from the command line in Windows 7 and Windows 8

If you have multiple displays or an external projector, you might be familiar with the built-in feature of Windows 7 and Windows 8 to change the active display and the sharing mode of your current desktop. When you press Win+P, you can choose to extend your desktop, duplicate it, or turn off one of the displays entirely. It is possible to control this feature via the command line, so you can create a shortcut any of these 4 settings. Let's see how it can be done.