It it possible to detect application focus event using applescript? What I'm trying to achieve is to open ios simulator when I focus on text editor. I know how to activate simulator but can't figure out how to detect when the editor is active.
Detect application focus event using applescript
applescript
Related Question
- MacOS – How to focus a specific window with applescript without doing an activate and bringing other windows to the front
- How to maintain focus on app window with AppleScript
- Open application from terminal and remain linked to the process (like Linux) so when CTRL+C is sent to terminal the application closes too
- MacOS – AppleScript set focus on terminal window
- MacOS – Detect battery percentage applescript
- How to use AppleScript to type text into a new window
- MacOS – Detect fn and function key simultaneously pressed
- Place page number in a Pages document using AppleScript
Best Answer
A simple solution, using AppleScripts immanent capacities
[I am a little ashamed to admit that due to an "unhappy localisation" I did not realise there is a perfectly suitable way to make AS-scripts repeat periodically. The English term "Stay Open Application" in its German version ominously re-translates to "Display after run-handler". ]
(I will leave parts of my workaround solution at the bottom, because of its own merit.)
This …
… is really all you need.
Save this code in ScriptEditor, check "Stay Open" application (or similar) and run the app.
(Close ScriptEditor if you like.)