I want to hide the frontmost app.
I know you can hide a process using the syntax:
tell application "System Events"
set visible of process "..." to false
end tell
and i know how to get the frontmost app:
(path to frontmost application as string)
But how do I bridge the two commands together?
This will not work:
tell application "System Events"
set visible of process (path to frontmost application as string) to false
end tell
Try this.
You have to be careful because in some ways when you run the script, the script is frontmost so you may just end up hiding the script instead of the application you were targeting. I check the name of the frontmost process, and if that matches the name of the script or “applescript runner” then you need to hide that, then run the command again and you’ll actually get the application you were targeting. It’s tricky.