Hi. Programming veteran, Applescript noobie here,
I’m making a script to automatically keep my windows arranged the way I like them.
I have one to marshal everything out of the reserved place on the left of the screen:
tell application "System Events"
repeat with theApp in application processes
if the name of theApp is not "Adium" and name of theApp is not "DashboardClient" and name of theApp is not "Finder" then
repeat with theWin in windows of theApp
set the position of theWin to {358, 22}
end repeat
end if
end repeat
end tell
This script works just fine.
Now, I want to make one specifically for Adium, to autosize the chat window accourding to the contact list height, move the file transfers box and log viewer, if they’re open.
I begin…
tell application "Adium"
repeat with theWin in windows
set a to the name of theWin
if a is "Contacts" then
set cWin to the number of theWin
set the position of theWin to {45, 22}
else if a is "Log Viewer" then
set lWin to the number of theWin
else if a is "File Transfers" then
set tWin to the number of theWin
else if a is "" then
set iWin to the number of theWin
else
set chWin to the number of theWin
end if
end repeat
set position of window cWin to {45, 22}
end tell
Both calls to “set position of window”… fail here, no matter what I do, with error:
"Adium got an error: Can't make position of item 3 of every window into type reference."
However I write it, no matter what I do, I can’t treat theWin the same way I treat it in the first script… what am I missing? The event viewer seems to look exactly like the output of the first script, too… so it’s not like the window properties aren’t there…
– Dexter
(Also, any other syntax tips are appreciated)
Model: Macbook Pro
AppleScript: 1.10.7
Browser: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.7) Gecko/20060911 Camino/1.0.3
Operating System: Mac OS X (10.4)