Skip to main content
edited body
Source Link
nohillside
  • 104.5k
  • 42
  • 222
  • 275

I need a script to open an app if it's not the frontmost app and hide(command+h) it when it is the frontmost app.

e.g 'Kim.app'

how to write this in Applescript or shell script?

Here is some info I can get:

Getfrontmost:

osascript -e 'tell application "System Events" to get name of application processes whose frontmost is true and visible is true'

osascript -e 'tell application "System Events" to get name of application processes whose frontmost is true and visible is true'

Open:

open -a 'Kim.app'

open -a 'Kim.app'

Hide:

osascript -e 'tell application "System Events" to set visible of process "Kim" to false'

osascript -e 'tell application "System Events" to set visible of process "Kim" to false'

still don't know how to write this

I need a script to open an app if it's not the frontmost app and hide(command+h) it when it is the frontmost app.

e.g 'Kim.app'

how to write this in Applescript or shell script?

Here is some info I can get:

Getfrontmost:

osascript -e 'tell application "System Events" to get name of application processes whose frontmost is true and visible is true'

Open:

open -a 'Kim.app'

Hide:

osascript -e 'tell application "System Events" to set visible of process "Kim" to false'

still don't know how to write this

I need a script to open an app if it's not the frontmost app and hide(command+h) it when it is the frontmost app.

e.g 'Kim.app'

how to write this in Applescript or shell script?

Here is some info I can get:

Getfrontmost:

osascript -e 'tell application "System Events" to get name of application processes whose frontmost is true and visible is true'

Open:

open -a 'Kim.app'

Hide:

osascript -e 'tell application "System Events" to set visible of process "Kim" to false'

still don't know how to write this

Source Link
user956609
  • 405
  • 2
  • 5
  • 12

How to use script to open an app if it's not the front most app, and hide it when it is the front most app in macos?

I need a script to open an app if it's not the frontmost app and hide(command+h) it when it is the frontmost app.

e.g 'Kim.app'

how to write this in Applescript or shell script?

Here is some info I can get:

Getfrontmost:

osascript -e 'tell application "System Events" to get name of application processes whose frontmost is true and visible is true'

Open:

open -a 'Kim.app'

Hide:

osascript -e 'tell application "System Events" to set visible of process "Kim" to false'

still don't know how to write this