1

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?

  • I curious to see if that code I added works for you – wch1zpink Feb 2 '17 at 2:34
2

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
  • 2
    Your solution works perfectly while testing the code in Automator. However, when I run the Service from within other applications (such as Google Chrome, TextEdit, and Microsoft Word), the window of the Hangouts app does not change, and I get the vague error, "The action “Run AppleScript” encountered an error." I think it may have to do with permissions or something. Do you have any idea how to fix this? Does your code work correctly (when triggered from within these applications) for you? – rubik's sphere Feb 4 '17 at 1:14
  • I just created that service through Automator and when I tried to run the service through Finder.. I got the same error message also. I went to system preferences/ security and privacy/ privacy-accessibility and added Finder app to the list of applications that can control my computer and BINGO. This service works. Apparently you will need to add any application that you would like to run that service through to the list of allowed applications in your system preferences. FYI.. The finder application is located here /System/Library/CoreServices/Finder.app – wch1zpink Feb 4 '17 at 2:16
  • 1
    Thanks for the tip. I would like my Service to change the bounds of the Hangouts window, while I am in any and every application on my computer. Ideally, I would not have to add every application on my computer to the list to get it to work (plus, I'd also have to do this any time that I downloaded a new application). But, this is out of the scope of my original question, which you've answered. I've created a new question to address this desire: How to rework a “System Events" AS command, so that it automatically works in all applications? – rubik's sphere Feb 4 '17 at 3:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .