Please, need help resizing windows using accessibility API

I want to write a script in AppleScript that resizes the currently focused window.

I wrote this in AppleScript (by looking at examples online):

set menubarHeight to 0
set screenWidth to 1440
set screenHeight to 849
tell application "System Events"
	set frontApp to name of first application process whose frontmost is true
end tell
if (frontApp is equal to "Finder") then
	set menubarHeight to 44
end if
tell application frontApp
	set bounds of window 1 to {0, menubarHeight, screenWidth, screenHeight}
end tell

It works on some windows, but not all applications (like Opera or Mozila).
So I read up that I need to use the accessibility API to do this.

However, I can not figure out how to use the API in AppleScript.

The thing is I am not a computer person persay, but I would like this script to make my computing experiences easier with OS X.

I am hearing I have to write this program with XCode but I do not know how to do that and do not have time to learn unless I really have to.

Can anyone help me out please???

What I was trying to do is have a few scripts that did these things:
-resize a window to take up the whole screen (less the menubar and dock)
-resize a window to take up the left half of the screen
-resize a window to take up the right half of the screen
-resize a window to take up the top half of the screen
-resize a window to take up the bottom half of the screen
-resize a window to take up the top left quadrent of the screen
-resize a window to take up the top right quadrent of the screen
-resize a window to take up the bottom left quadrent of the screen
-resize a window to take up the bottom right quadrent of teh screen

Any help would be greatly appreciated. I have been trying to figure this out for days no.

Thank You

Model: MacBook Pro
Browser: Firefox 1.5.0.6
Operating System: Mac OS X (10.4)

Nacho,

Here is a link to a question I posed about resizing a window in Illustrator. Kai posted a useful bit of code. Currently, on my home computer, I have AppleScript 1.9.2 and OS 10.3 and I don’t think this particular command works for this version because it errors. However, I know it works on my work computer (OS 10.4.7). Here’s the link.
http://bbs.applescript.net/viewtopic.php?id=16110

PreTech

Thanks sooooo much.
That worked beautifully.

Now I can resize windows nicely with a quick keystroke.

I have dual screens and haven’t properly thanked Kai for this either. Many apps have a “position” property (instead of “bounds”), so since I like to keep browser windows on my second display (I have two), I can use this much of Kai’s script to move the window where I want it as well (using a hot key). I have Extra Suites, but it’s not necessary in this instance, as Camino, Safari, and Shiira all leave scroll bars intact:


tell application "System Events" to tell process "Camino"
	tell window 1
		if position is {1155, 104} then -- it's on display 2, switch it to 1
			set position to {51, 25}
			set size to {1087, 834}
		else -- it's on display 1, switch it to 2
			set position to {1155, 104}
			set size to {1018, 762}
		end if
		--set p to position of grow area 1
	end tell
	set frontmost to true
end tell
(*
tell application "Extra Suites"
	ES move mouse p
	ES click mouse
end tell
*)

I wonder if there is a way to set default size and position values for certain programs.
That way, when you open them, they always open inthe same place.

If you don’t move it or resize it, most apps remember the postion and size of the frontmost window when you quit.