As far as I can tell, there is no easy way. I found one very crude method for getting the maximum and minimum window size.
It includes setting the width and height to a very large number to see how far the window resizes, remembering that size as maximum, and then setting the width and height to a small number and doing the same thing again. In the end, I just reset the width and height to their original values.
The obvious problem is that it is very noticeable to the user that the window has been resized.
As for the resizing increments, I cannot come up with (at the moment) a workaround to get this information.
In any case, here is the code that I have for developing the maximum and minimum size:
AXUIElementRef window; // The window AXValueRef sizeValue = (AXValueRef)[UIElementUtilities valueOfAttribute:@"AXSize" ofUIElement:window]; CGSize windowSize; AXValueGetValue(sizeValue, kAXValueCGSizeType, &windowSize); CGFloat windowWidth = windowSize.width; CGFloat windowHeight = windowSize.height; // Set it to a very large number [UIElementUtilities setStringValue:@"w=5000 h=5000" forAttribute:@"AXSize" ofUIElement:window]; AXValueRef maxSizeValue = (AXValueRef)[UIElementUtilities valueOfAttribute:@"AXSize" ofUIElement:window]; CGSize maxWindowSize; AXValueGetValue(maxSizeValue, kAXValueCGSizeType, &maxWindowSize); CGFloat maxWindowWidth = maxWindowSize.width; CGFloat maxWindowHeight = maxWindowSize.height; NSLog(@"max width = %f. max height = %f.", maxWindowWidth, maxWindowHeight); // Set it to a very small number [UIElementUtilities setStringValue:@"w=0 h=0" forAttribute:@"AXSize" ofUIElement:window]; AXValueRef minSizeValue = (AXValueRef)[UIElementUtilities valueOfAttribute:@"AXSize" ofUIElement:window]; CGSize minWindowSize; AXValueGetValue(minSizeValue, kAXValueCGSizeType, &minWindowSize); CGFloat minWindowWidth = minWindowSize.width; CGFloat minWindowHeight = minWindowSize.height; NSLog(@"min width = %f. min height = %f.", minWindowWidth, minWindowHeight); // Reset size [UIElementUtilities setStringValue:[NSString stringWithFormat:@"w=%fh=%f", windowWidth, windowHeight] forAttribute:@"AXSize" ofUIElement:window];
If you're interested, UIElementUtilities is the class I took from one of Apple's projects called UIElementInspector .
Joshua
source share