Trying to hide Trillian once it logs in

Been messing around with this today.
At the moment, if I run Trillian in the login items, it’s too quick for my Wifi and tells me the connection fails.
Simple fix for that is obviously just a simple delay script. So I did that with no problems.

That got me thinking- since I’m already writing a script, why not get Trillian to do what I want it to when I launch it- hide the contact list window as soon as it’s signed in. Sort of like a silent login.

I’ve been using UI Browser a bit trying to work out what the best approach is. The closest I’ve come with limited success is this:

delay 3
activate application "Trillian"
tell application "System Events"
	tell process "Trillian"
		get title of window 1
		if title of window 1 is "Trillian" then
			click button 1 of window 1
		else
			delay 0.5
			repeat until title of window 1 is "Trillian"
			end repeat
			click button 1 of window 1
		end if
	end tell
end tell

The signing in window doesn’t have a title. If I run just the get title of window 1 for the signing in window, it comes back in the results as “”.
So this idea above basically waits until the title of window 1 is Trillian, then clicks close on that window (contact list).
It seems to work if I’ve got another application window open. For example, I just tried running the script with this Firefox window open that I’m typing this into, and it worked just fine.
However, if I minimize FF, I get the error: “No result was returned from some part of this expression.” number -2763
Or if I save it as an app, I get "Can’t get window 1 of «class prcs» “Trillian” of application “System Events”. Invalid index.
I’ve also had that error when running it from Applescript Editor once or twice.

I don’t know if I’m going about this the right way or not. So if anyone’s got any suggestions of how to fix what I’ve done, or a better way of doing what I’m trying to do, please post!

Running 10.6.5

I think the problem occurs between the sign in window closing and the contact list window opening.
One other option I thought of was instead of getting the window title, get the enabled of button 2 (zoom), because in the sign in window it’s false but in the contact list window it’s true.
Then I could do something like:

delay 3
activate application "Trillian"
tell application "System Events"
	tell process "Trillian"
		get enabled of button 2 of window 1
		if enabled of button 2 of window 1 is "True" then
			click button 1 of window 1
		else
			delay 0.5
			repeat until enabled of button 2 of window 1 is "True"
			end repeat
			click button 1 of window 1
		end if
	end tell
end tell

However, I’ve tried this and it seemed to give me the same error at the same place as the first script.

Success with the latter. Must have been doing something wrong the first time.
This is what’s working successfully:

delay 3
activate application "Trillian"
tell application "System Events"
	tell process "Trillian"
		get enabled of button 2 of window 1
		if enabled of button 2 of window 1 is true then
			click button 1 of window 1
		else
			repeat until enabled of button 2 of window 1 is true
				delay 0.1
			end repeat
			click button 1 of window 1
		end if
	end tell
end tell