tell application "System Events" to tell process "UScript" to set the position of 1st window to {974, 23}
and when I called it from the UScript(a app i made on mac), i got the error:
Can’t get window 1 of <> 1 of application “System Events” whose frontmost = true. Invalid index.
but the it works fine when i run it in script editor
activate application "UScript"
tell application "System Events" to tell process "UScript"
set frontmost to true
log (get properties of first window)
set the position of first window to {974, 23}
end tell
With your original script, we didn’t knew if the application “UScript” is active when you call the script.
We were no more sure that it is at front.
With the edited code both status are guaranteed.
I added a log instruction which will tell you if there is really a window available belonging to the application.
Yvan KOENIG running El Capitan 10.11.1 in French (VALLAURIS, France) vendredi 23 octobre 2015 15:46:36