I want to resize any window on my machine, which I accomplish with AppleScript, using GUI Scripting. The script looks similar to the following:
tell application "System Events"
set appProcess to the first process whose name is "Finder"
set appWindow to the front window of appProcess
set position of appWindow to {100, 100}
set size of appWindow to {10, 10}
end tell
Even though I set the width and height to 10px, the Finder will resize to at least a width of 344px and a height of 236px. I tested this with other applications and all had a minimum width, which differed depending on开发者_如何学运维 the application. For example, TextMate windows have a size of at least 213px * 129px.
Since I sometimes need to resize the windows to a smalled width and height, is there a way to override this minimum size, i.e. that my values are used even though they are "too small"?
If not, I need to know the minimum size, so that I know that the window will be bigger than expected. How would I accomplish that?
The concrete problem is the following: I am writing a window tiling manager, therefore I need to be in charge of the size of the windows. The minimum size creates to problems:
- My tiles may be too small for windows of a certain application, therefore the windows may overlap in other tiles.
- The window may be wider / higher than expected and therefore cross the borders of my screen. (For example, the window is near the lower right corner of my screen - I set the width and height accordingly to fit in the corner, but since it has a minimum size it won't fit.)
I am thankful for any recommendations. :)
Best wishes
FlorianAs the commenters pointed out: It is not possible to resize a window below its minimum size which was set during development (e.g. in Interface Builder). However, minimum sizes are there for a reason: To prevent auto-resizing problems, e.g. buttons overlap or disappear due to a too small view size.
Thanks to Bavarious for that answer.
PS: Lri added, that it may be possible to bypass minimum sizes using the API of an application, e.g. using the Carbon API to resize iTunes or using customly build AppleScript-APIs. Thanks Lri!
精彩评论