Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 298
Chase Avatar asked Feb 03 '26 20:02

Chase


1 Answers

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

tell application "Terminal"
    reopen
    activate
end tell
like image 158
Lri Avatar answered Feb 05 '26 11:02

Lri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!