|
|
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
Snapshot: 2026-04-27T03:23:40Z
Generator: Remarkbox 97a1fff