Skip to content

Instantly share code, notes, and snippets.

@yueyericardo
Last active January 8, 2019 05:14
Show Gist options
  • Save yueyericardo/376229d0f51e32ec73ad0f54627ba216 to your computer and use it in GitHub Desktop.
Save yueyericardo/376229d0f51e32ec73ad0f54627ba216 to your computer and use it in GitHub Desktop.
hide_all in mac
on run {input, parameters}
	
	tell application "System Events" to set all_apps to the name of every process whose visible is true
	
	repeat with a in all_apps
		tell application "System Events" to try
			keystroke "h" using command down
			delay 0.1
		on error
			activate
			tell application "System Events" to repeat (count windows of process a) times
				keystroke "m" using command down
				delay 0.1
			end repeat
		end try
	end repeat
	
end run
on run {input, parameters}
	activate application "Finder"
	tell application "System Events" to keystroke "h" using {option down, command down}
	delay 1
	tell application "System Events" to keystroke "w" using {command down}
	
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment