<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/2fc4f7e2-4208-11e9-9d31-040140774501](https://my.remarkbox.com/2fc4f7e2-4208-11e9-9d31-040140774501)  
> **Snapshot:** 2026-04-27T03:25:02Z  
> **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,iVBORw0KGgoAAAANSUhEUgAAAJQAAACUAQAAAABdRz15AAABJklEQVR42s1WMQ7DQAyy+gH+/0t+4AJOpy6V7KFRhrsMCBuwU/31sP7qW1UBRRCNXPiq7+fXbyWQNlIe+LLFMz2QbL2+HOCZWFGHIzxxg043eGpZWQ+376B/0ffzHOgb20TcyKvLsl5LIWZtA0rhLT8GsHXwkev+dSUdRb1QYNZ4o6xbKFPXPh9wmQbqKX9dr1sXxNS91sMMHQ+OOPv+YUYLUvnafxJhgmtF4po9P6OKXKXyvV/s4ifKF/5TOpQP87PE63p7XOd5wIN5pY6ZXD3+28+/pM2A8eDef+bniQXbZe+XDD/r6qJr7+eOjfEsdJzsD28NXO1Lbw5GmBn9F/vX+2Oo9tE+L0/8pPji/2WGqv3Hi/5xDIgE7kJfjho46N9//+++ASh2aQIU2JyIAAAAAElFTkSuQmCC)

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

This is a very weird bug. Seems like it just doesn\'t want to work
inside the\
`System Events` tell. If you do the following it works. It\'s kinda ugly
but I\
think it\'s because if you do a `tell` inside another `tell` then the
second\
goes through the first. So in the original you\'re telling
`System Events` to\
tell `Mail` to activate.

    set appName to "Mail"
    set startIt to false
    tell application "System Events"
      if not (exists process appName) then
        set startIt to true
      else if frontmost of process appName then
        set visible of process appName to false
      else
        set frontmost of process appName to true
      end if
    end tell
    if startIt then
      tell application appName to activate
    end if

But what\'s even more weird is that this works,

    set appName to "Mail"
    set startIt to false
    tell application "System Events"
        if not (exists process appName) then
            tell application "Mail" to activate
        else if frontmost of process appName then
            set visible of process appName to false
        else
            set frontmost of process appName to true
        end if
    end tell
    if startIt then
        tell application appName to activate
    end if

but this does **not** work as you probably already know,

    set appName to "Mail"

    tell application "System Events"
      if not (exists process appName) then
        tell application appName to activate
      else if frontmost of process appName then
        set visible of process appName to false
      else
        set frontmost of process appName to true
      end if
    end tell

Also you can use `exists` instead of `name of every`\
`process ..`.


---

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