<table class="provenance-header" style="border: 0; border-collapse: collapse; margin: 0 0 16px 0; width: 100%;">
<tr style="border: 0;">
<td style="border: 0; vertical-align: top; padding: 0 24px 0 0;">

> **Source:** [https://my.remarkbox.com/2fc4f7e5-4208-11e9-9d31-040140774501](https://my.remarkbox.com/2fc4f7e5-4208-11e9-9d31-040140774501)  
> **Snapshot:** 2026-04-27T03:27:05Z  
> **Generator:** Remarkbox `97a1fff`  
>
> *This is a subthread snapshot. The living document lives at the source URI above — it may have been edited, extended, or replied-to since.*

</td>
<td style="border: 0; vertical-align: top; width: 200px; text-align: right;">

![Scan for living source](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAACUAQAAAABdRz15AAABLklEQVR42s2WQY7EQAgD0XyA///SP2Bdzuxe5rISHKYVJd05WGCMm5qPpfqqf1XV8rb55PCqz/XffzU9ecTz7JZ41U1kreocDvCMJGd6hweBGvUFnikzSKnVF/xR0r91UF9Wk63TfTS05c8hOV0jF/stHjIxebyUzTZfwRvJKlLcxjdVD3NkncOSP8hDMLSHt7PWi4MjbeOWOdzrBd7I1aFR5n2/OTbekcu+HmglYnEbq9b9BneODV2bTB34KR8rELvShf5cWawl1d3rzygG6/c1cqC/YOhXf3s/jUoe46Lh1vrLbYTLJMyb/gXqXZIjfwZsOtHu7w/AEmKc8OB+48JUTLpO5oNMB+kUzQmey4BdZSo6mjemnxHsYr5ymvgfVM5BfePPaWWt+fvuefcHA8tqahXLU+YAAAAASUVORK5CYII=)

</td>
</tr>
</table>

Final solution. Don\'t know whether this is better than other solutions.
I guess it is *one* way to do it \...

    set appName to "Safari"
    set alreadyLaunched to false

    tell application "System Events"
        if not (exists process appName) then
            set alreadyLaunched to false
        else
            set alreadyLaunched to true
        end if
        set frontmostApp to name of the first process whose frontmost is true
    end tell

    if alreadyLaunched is false then
        tell application appName to launch
    else if alreadyLaunched is true then
        if frontmostApp is equal to appName then
            tell application "System Events" to set visible of process appName to false
        else
            tell application appName to activate
        end if
    end if

## D Curtis — [Jan 23, 2011 08:56 am](https://my.remarkbox.com/2fc4f7e0-4208-11e9-9d31-040140774501/quick-tip-applescript-application-toggle-brettterpstra-com#2fc4f7e6-4208-11e9-9d31-040140774501)

\@Zett activate will bring the app to the front whether it is open or
not. So really, all you need to do is check if the app you\'re looking
for is frontmost. If it is, you hide it. If it isn\'t, you activate it.
Ideally this should work but I don\'t care enough anymore to test it.

    set appName to "Mail"
    set needsActivation to false
    tell application "System Events"
      if frontmost of process appName then
        set visible of process appName to false
      else
        set needsActivation to true
      end if
    end tell

    if needsActivation then
      tell application appName to activate
    end if


---

**Source:** [https://my.remarkbox.com/2fc4f7e5-4208-11e9-9d31-040140774501](https://my.remarkbox.com/2fc4f7e5-4208-11e9-9d31-040140774501)  
**Snapshot:** 2026-04-27T03:27:05Z  
**Generator:** Remarkbox `97a1fff`
