How to change the size of a Google Hangouts window in AppleScript

applescriptgoogle-hangoutswindow-manager

Using AppleScript, I want to set the bounds of the window for the Google Hangouts desktop application.

The application file is located at:

/Users/Me/Applications/Chrome Apps.localized/Default knipolnnllmklapflnccelgolnpehhpl.app

(I have no idea why the application name is knipolnnllmklapflnccelgolnpehhpl.)

I've tried the following

tell application "Default knipolnnllmklapflnccelgolnpehhpl" to set bounds of front window to {405, 23, 1037, 633}

but I am given the error:

Default knipolnnllmklapflnccelgolnpehhpl got an error: Can’t get
window 1. Invalid index.

So, then I thought, "The Hangouts application must not be scriptable."

I tried the method provided in this answer to change the window size for a non-scriptable application via System Events:

set theSBounds to {{405, 23}, {1037, 633}} 

tell application "System Events"
    set size of front window of application process "Default knipolnnllmklapflnccelgolnpehhpl" to item 1 of theSBounds
    set position of front window of application process "Default knipolnnllmklapflnccelgolnpehhpl" to item 2 of theSBounds
end tell

but I am given the error:

System Events got an error: Can’t set application process "Default knipolnnllmklapflnccelgolnpehhpl" to {405, 23}.

After opening the dictionary for the Google Hangouts app via Script Editor.app, I realized that the app is in fact scriptable and can respond to bounds. The app is compatible with both the standard and text AppleScript suites.

Does anyone know how to set the bounds for this application?

Best Answer

This works for me with my actual Gmail information inserted at the two appropriate places in the script


tell application "Default knipolnnllmklapflnccelgolnpehhpl"
    activate
end tell
tell application "System Events"
    set theSBounds to {{405, 23}, {1037, 633}}
    set position of window "Google Hangouts - username@gmail.com" of application process "Google Chrome" to item 1 of theSBounds --replace username@gmail.com with your actual Gmail information
    set size of window "Google Hangouts - username@gmail.com" of application process "Google Chrome" to item 2 of theSBounds  --replace username@gmail.com with your actual Gmail information
end tell