With the following AppleScript code within a "Run AppleScript" action in a Service:
tell application "System Events"
set theSBounds to {{572, 64}, {332, 515}}
set position of window "Google Hangouts - myemailaddress@gmail.com" of application process "Google Chrome" to item 1 of theSBounds
set size of window "Google Hangouts - myemailaddress@gmail.com" of application process "Google Chrome" to item 2 of theSBounds
end tell
the Service will only work if the application from which that Service has been called has been added to the list of applications under "Allow the apps below to control your computer." This list is found at System Preferences → Security & Privacy → Accessibility.
Is it possible to modify the AppleScript code somehow so that adding every application on one's computer to the list is not necessary? Or, so that, one only needs to add one item to the list, as opposed to every application on one's computer?
I thought that something like this might work:
do shell script "osascript -e 'tell application \"System Events\"' -e 'set theSBounds to {{572, 64}, {332, 515}}' -e 'set position of window \"Google Hangouts - myemailaddress@gmail.com\" of application process \"Google Chrome\" to item 1 of theSBounds' -e 'set size of window \"Google Hangouts - myemailaddress@gmail.com\" of application process \"Google Chrome\" to item 2 of theSBounds' -e 'end tell'" with administrator privileges
but this code also requires that the application from which the Service is run is added to the Accessibility list.
Note: I only want to run this AppleScript as a Service, and not in an Automator-created Application, because the code receives selected text as its input (system-wide).