How to get and/or overwrite the minimum size of windows in Mac OSX
Asked Answered
D

1

6

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:

  1. My tiles may be too small for windows of a certain application, therefore the windows may overlap in other tiles.
  2. 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
Florian

Dauntless answered 24/4, 2011 at 11:35 Comment(5)
You could edit the nib files and set a different minimum size for the windows!Weddle
Seriously, though, applications set minimum sizes for their windows in order to prevent autoresizing problems, which can make some views disappear and do not show up when the window size is enlarged. From what I’ve gathered, it looks like you cannot query or set the minimum size from AppleScript.Weddle
Seems like you are right, because the tiling manager Divvy can't set a smaller size either. Too bad that I cannot query the minimum size, so I need a workaround. The only workaround which comes into my mind is setting the size I wish, getting the real size and move the window if the real size differs from the size I set / demanded.Dauntless
You can bypass the minimum size limit with Carbon applications, for example iTunes. But there's no way to bypass it in general using just AS. And seriously, applications like Divvy aren't tiling window managers.Keyway
@Bavarious If you turn your comment into an answer, I will gladly accept it. :) @Keyway It's the best description I have. I know, xMonad is a true window tiling manager, but what about all those other options out there? (Divvy, OptimalLayout, Arrange, ...)Dauntless
D
-2

As 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!

Dauntless answered 12/3, 2012 at 19:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.