Set position of window with AppleScript

DrummerB picture DrummerB · Oct 9, 2012 · Viewed 16.8k times · Source

I'm trying to set the position of the Messages.app chat window using AppleScript.

tell application "System Events"
    set position of window 1 of application "Messages" to {100, 100}
end tell

With this code I get an error:

error "Messages got an error: Can’t set «class posn» of window 1 to {100, 100}." 
number -10006 from «class posn» of window 1

What does that mean?

If I try the same code with Finder it works. But most of the other applications don't work.

Answer

Parag Bafna picture Parag Bafna · Oct 10, 2012
tell application "System Events"
    set position of first window of application process "Messages" to {100, 100}
end tell  

Enable Access for assistive devices to run this script.

enter image description here