maxischl
maxischl

Reputation: 631

Applescript: stay open application, do something different when clicked a second time

I have a Little AppleScript saved as a stay open application. Activating the application executes "run".

By its stay open nature, the script does not quit itself.

Is it possible to register if the application itself is already running and clicked a second time?

I have struggles with that, since the script is not executed at all when the application is running already.

Also, On the second click, I do not want to check if the first run was successful (in this case: I do not want to check if safari is running).

I just want t do something totally different.

on run
    tell application "Safari" to activate
end run

    --somehow check for second start here...

on idle
    beep
    return 5
end idle

Upvotes: 0

Views: 379

Answers (1)

vadian
vadian

Reputation: 285082

A double-click on the application icon or a single click on the dock icon calls the on reopen handler

on reopen
    --somehow check for second start here...
end reopen

Upvotes: 1

Related Questions