I'm starting to use the Application Switcher now that LiteSwitch X no longer works in Catalina, but there is one feature of LiteSwitch missing - "Switching sends re-open event" - that I'm trying to implement using a post-switch action.
I have the action set up after the switcher (see below), but the problem is that it runs immediately after the switcher is activated, while the original app is still frontmost. I want it to run after the switcher dissapears, and act on the destination app. Is there any way to do this?
I've tried testing for %ActionResult% after the switcher action, but that variable does not seem to be generated by the switcher. I would also try a timer, but that probably won't work if the switcher is active for several seconds.
Here is the AppleScript action to activate a window. I don't remember where I found it, but thanks to the author!
If All Conditions Met
The text “%ActionResult%” is “OK”
Execute the Following Actions:
Execute AppleScript"
set front_app to (path to frontmost application as Unicode text)
tell application front_app
if windows is {} then reopen
end tell
To answer my own question, I made a separate action, triggered by the activation of specific applications:
Triggered by any of the following:
Trigger iconApplication “Safari” activates
Trigger iconApplication “Mail” activates
Trigger iconApplication “Finder” activates
Will execute the following actions:
Execute AppleScript
set front_app to (path to frontmost application as Unicode text)
tell application front_app
if windows is {} then reopen
end tell
One could also trigger this behavior when ANY application activates. For me, a select list is actually better because the reopen event is not always desirable. For example, Evernote will reopen the note list even if a note is already open in a separate window.
So I guess this thread becomes a suggestion rather than a question.
This is great, thank you! Dumb question, however, as I'm not much of an AppleScript guru -- how do you trigger this before when any application activates?
Or, better yet, is there a way to have a "black list" of applications that won't have their windows reopen, as opposed to a "white list" like your snippet?
Yes, you can make a black list by triggering the action when any application activates, and then put the action in a group which excludes the black list.
I've done this with only Evernote in the black list and so far it seems to work well.