Activate an Application in BACKGROUND mode (or Hidden mode? )

I have a CRON job running to make sure that the Calendar is running and I then hide it.
Is it possible to do this without the App window flashing briefly on the "front" screen.

Calendar may or may not
1: be open
2: be minimised
3: be the front screen
when the job runs.

Having just written the above, I have realised that I can modify the macro to

IF Calendar is NOT running
THEN
Save Current app from front window
Activate Calendar with
a: Unticked all windows
b: Unticked Reopen initial windows
c: If at front, hide the application
Restore the saved app back to front window

which should mean it only flashes if it was not running in the first place and not every time the CRON job runs.

However, in V8 we have the new condition tests

  • is hidden. (v8+)
  • is running but hidden. (v8+)
  • is not hidden. (v8+)

I do not understand what hidden means?
Is it the same as Minimised ?
or does it mean App window is hidden by other App windows?
Does it mean the App is running?
Does the condition test an application is active also include applications that are running but hidden?

Is there a KM action to make a program hidden, if so, why would you do this?

and finally my original question of
"can you activate an app in "background" mode so does not flash on the front screen?

still applies.

Try the following in an AppleScript action:

run application "Calendar"

If Calendar isn't already running it will launch it hidden, if Calendar is already open it will leave it in the current state (hidden or visible) -- so it's probably quickest to run the action without any checks at all! But if you don't like the thought of needlessly running a script then yes, tuck it into your "If Calendar is not running..." action.

2 Likes