Search code examples
macosapplescript

Bring a window to front in applescript


This is probably a total newbie question but here it is. I am making a pure applescript application. It activates another app and then types. The problem is that when it activates the app, it doesn't bring the apps window to the front. I tried telling the app to activate:

tell application "app_name.app"
activate
tell application "System Events" to keystroke "test"
end tell

Any help? Thanks!


Solution

  • If the target application has no open windows, you have to reopen a default window:

    tell application "Terminal"
        reopen
        activate
    end tell