Auto hide all other apps when clicking on an app’s window

Solution 1:

Assuming I understand your question correctly, you can do exactly what you want by holding the optioncommand keys down as you click on the window.

Also, if you just want to hide the last app (i.e. not all other apps) you can just hold down the option key while you click on the other window.

Solution 2:

You could activate the Single Application Mode. Here's what it does:

  • you have five TextEdit windows open in various locations on screen
  • you're currently using Safari
  • you navigate to the TextEdit window that's in the background by clicking it's icon in the dock
  • all other apps will be hidden automatically

You can activate Single Application Mode by opening /Applications/Terminal, then simple copy the following command:

defaults write com.apple.dock single-app -bool true; killall Dock

To reverse this behaviour, simply replace true with false.