Otherwise, you can employ a reasonably robust GUI-scripting workaround (gratefully adapted from a generic solution here):
![mac os program goes inactive and then reactivates mac os program goes inactive and then reactivates](https://www.imore.com/sites/imore.com/files/styles/xlarge/public/field/image/2017/01/snapchat-reactivate-account.jpg)
If your next action will be to click somewhere on the window anyway, this may not be a problem, as such a click will fully activate the desired window. You can tell by the inactive close/min/zoom title-bar buttons, by what window title the checkmark is next to, and by the fact that keyboard shortcuts such as Cmd-L will not apply to the desired window. While the solution will show the desired window as the front window, Chrome will NOT treat it as the front window if a different window was previously active. While adayzdone's answer should work and almost does, there is a catch - which may or may not be a problem (observed on Chrome. tell application "Google Chrome" to my activateWin(it, window 2).User495470's answer hints at a robust and generic solution that also works with non-AppleScriptable applications: tell application "System Events" to tell process "Google Chrome"Īlternatively, use the AppleScript handler defined below as follows:
![mac os program goes inactive and then reactivates mac os program goes inactive and then reactivates](https://data2.manualslib.com/first-image/i36/177/17605/1760493/sportiq-smart-tag-st008.jpg)
It does, however, have the advantage of not requiring the calling application to be authorized for assistive access, unlike the following solutions. Yar's answer offers a pragmatic workaround, though it's not entirely clear why it works.
![mac os program goes inactive and then reactivates mac os program goes inactive and then reactivates](https://support.apple.com/library/content/dam/edam/applecare/images/en_US/macos/Big-Sur/macos-big-sur-settings-network-hotspot-iphone-usb-make-service-inactive-selected.jpg)
Workarounds (examples assume you want to activate window 2): Using set index of window to 1 isn't fully effective in that it doesn't truly activate the window - it does make it visible, though.