I am working on an application that moves and resizes windows of other applications on OSX. The main application is written in Cocoa, but part of the resizing is done in AppleScript, because Cocoa does not seem to have this feature.
Here is the result of a regular ActionScript call (passed as a string to NSAppleScript):
tell application "TextEdit"
set currentWindow to the window id 5184
set bounds of the currentWindow to {2855, 218, 3790, 578}
end tell
The window identifier is obtained using the CGWindowListCopyWindowInfo API introduced in OSX 10.6.
This approach is great for most windows, but not for apps that are not subject to registration. The most striking example is the OSX preview.
I tried to “tell” system events instead of previewing using variants of this code.
tell application "System Events"
set bounds of window 5184 to {1920, -502, 2855, 578}
end tell
OSX :
"System Events got an error: Can’t set bounds of window 5184 to {1920, -502, 2855, 578}."
:
tell application "System Events"
get window 5184
end tell
, , .
OSX?
, , moom.
- Cocoa - AppleScript-based - - .