Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript: return focus to another app after script runs

I'm currently running the following script via Hazel to back up plain text notes in a specific folder to Evernote:


tell application "Evernote"

activate

create note from file theFile notebook {"!inbox"} tags {"to review"}

end


Is there any way to do this so it happens in the background i.e. returns focus to whatever app was active when the script is triggered?


Thanks in advance for any responses.

Posted on Feb 8, 2015 2:22 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 8, 2015 2:33 AM

Ah— solved.


tell application "System Events"

set frontmostApplicationName to name of 1st process whose frontmost is true

end tell


tell application "Evernote"

activate

create note from file theFile notebook {"!inbox"} tags {"to review"}

end tell


tell application frontmostApplicationName

activate

end tell

1 reply
Sort By: 
Question marked as Top-ranking reply

Feb 8, 2015 2:33 AM in response to Jacob Sam-La Rose

Ah— solved.


tell application "System Events"

set frontmostApplicationName to name of 1st process whose frontmost is true

end tell


tell application "Evernote"

activate

create note from file theFile notebook {"!inbox"} tags {"to review"}

end tell


tell application frontmostApplicationName

activate

end tell

Reply

Applescript: return focus to another app after script runs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.