I don’t think this is possible, but does anyone know if you can resize a window in Ill CS with AppleScript?
Thanks.
PreTech
I don’t think this is possible, but does anyone know if you can resize a window in Ill CS with AppleScript?
Thanks.
PreTech
I can’t test this specifically with Illustrator, PreTech - but it works on a wide range of Cocoa and Carbon apps:
tell application "System Events" to set size of window 1 of process "Finder" to {800, 400}
(* modify process name and window size as required *)
In many cases, the plural form should also work:
tell application "System Events" to set size of windows of process "Finder" to {800, 400}
Recent applications on which I’ve successfully used this approach include: Address Book, Adobe Photoshop 7.0, Adobe Reader, AppleWorks 6, Automator, Calculator, Chess, Console, Dictionary, DropStuff, Finder, iCal, iMovie, iPhoto, Mail, Microsoft Excel, Microsoft PowerPoint, Microsoft Word, Preview, Safari, Script Editor, Sherlock, Skype, Terminal, Tex-Edit Plus, TextEdit and Xcode. Since this includes a couple of Adobe apps, let’s hope that Illustrator is equally co-operative…
Kai,
As always, you seem to have a solution. Another question though, if i may? I don’t know if anyone else has experienced this (because I seem to have some sort of strange effects on electronic equipment that no one else can reproduce), but when I use the above script on Illustrator (it does resize the window) the window looses its right scroll and down scroll arrows (lower right hand screen). The function (command & 0 (zero)) used to fit the document to the window does not work. However, when I grab the resizing corner and move it a little the arrows come back and the function works. The only other time I have experienced this is in using Xcode and looking through the documentation. This is probably not any kind of AS issue, but if you have any insight, it would be appreciated.
Thanks.
PreTech
Model: dual 1.8 G5
AppleScript: 2.1 (80)
Browser: Safari 412.5
Operating System: Mac OS X (10.4)
Just another lucky guess, I suppose, PreTech.
Yeah - I’ve noticed the behaviour you describe in one or two Carbon apps, such as AppleWorks and Photoshop. There are some additional curiosities relating to the behaviour of these applications. If already frontmost, for example, the window resizing method described above doesn’t work. Moreover, many window UI elements become inaccessible (as if they no longer exist).
With the applications I’ve tested, resizing the window manually (by dragging a window’s grow area) restores the scroll bars - as it does in your experience. Even clicking the grow area achieves a similar result here. Unfortunately, though, the grow area is not configured to respond to a UI scripted click (action “AXPress”) - so that doesn’t help us very much in this context.
What should work (but unfortunately never has) is the click at {x, y} form of the click command.
That rules out pretty much every potential vanilla solution I’ve thought of so far. As things currently stand, the only suggestion I can make is to engineer a click using third-party software, such as the background scripting application, Extra Suites. While not free, this is reasonably priced - and you can download it to try before you buy.
This works here (requires Extra Suites):
tell application "System Events" to tell process "AppleWorks 6" (* change application as required *)
tell window 1
set size to {640, 480}
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
Kai,
Thanks once again. I’ll look into the Extra Suites.
PreTech