Resizing game app window

How can I resize game app window using applescript. Any idea please…


I made up this for you to play with, change “Safari” to game app. The postion, is also a list with two items, x is the first, and y the second of it.

tell application "System Events"
	tell process "Safari"
		set {pos, siz} to {position, size} of its window 1
		set wdth to item 1 of siz
		set hgth to item 2 of siz
		set item 1 of siz to wdth - 300
		set item 2 of siz to hgth - 300
		set size of its window 1 to siz
	end tell
end tell


I got the following error, did not even gave me a chance to use my game app name. Can you help me more?

error “System Events got an error: Can’t get window 1 of process "Safari". Invalid index.” number -1719 from window 1 of process “Safari”.

OS X version 10.7.5 user


How sloppy of me!

Go to system preferences, ”> Special needs? and enable Access for assistive devices, and please try again!

I am sorry, I forgot to mention that this option must be enabled, (it is within the preference pane rached by a man as its icon), for ui scripting to work.

At least that is the end we’ll start figuring out what’s wrong.

I have enabled access for assistive device yet I’m still having the same error message.

in the tell process line replace “Safari” with the name of the game app


You also need to have the web browser Safari up and running, and a window of it open, for it to work with Safari.

I say this because the error code −1719, is an index out of range error, so I just want to ascertain the circumstances when you run the script.

script works with safari but when i tried changing safari to the game app name I had the following error message:

error “System Events got an error: Can’t get process "Grimm’s Red Riding Hood".” number -1728 from process “Grimm’s Red Riding Hood”

Hello run this script from the script menu when the game is running, and be sure you get the name right.

Just keep the script, as maybe we’ll have to do something else, in order to get the process name, that System Events can use.

tell application "System Events"
	tell (first application process whose frontmost is true)
		set a to name of it
		set b to bundle identifier of it
	end tell
end tell

tell me
	display dialog "Appname is : " & a
end tell