Programmatically change height of the window more than the height of the screen in Mac OS X - objective-c

Respected low-level users of Mac OS, please, help.
I'm trying programmatically to change height of window of safari (or other window). I'm was trying used AppleScript and AXUIElementSetAttributeValue of Carbon, but none of these methods can't increase the window bigger than the height of the screen. But, the width changes without any problems.
I guess I'd be starting with something like SetWindowPos with SWP_NOSENDCHANGING flag under Win32.
Maybe, you can disable this functionality, which monitors the size of the window or completely shutdown the one who is responsible for it?
Note that I want to do this programmatically from an external process - I'm not asking how to control just my own app's window size and position.
Thanks.

It's not possible, search for "Note that any NSWindow with a title bar automatically constrains itself to the screen" in the Window Programming Guide.

Related

How to disable accessibility support for the divider of a NSSplitView?

I have a NSSplitView in my app. Its divider position is fixed, the user is not able to drag the divider around. Now I am adding support for accessibility. When using VoiceOver, the user can select & drag the divider. That breaks my UI.
How can I tell VoiceOver, that it should ignore the divider?
I am using the new Accessibility Protocol available since OS X 10.10.
Setting splitView.isAccessibilityElement or splitView.isAccessibilityEnabled to no does not work.
Thanks for your help!
Ok, I asked a nice guy from the AppKit team at WWDC.
He told me that this is not possible at the moment - because I can not acces the divider within the splitView.
Explanation:
Disabling the accessibility support on a NSView, makes the particular view inaccessible, but not its sub view - which is the desired behavior normally
Since the divider is a subview of NSSplitView, this does not work.
Solution:
I ended up not using NSSplitView anymore because I don't need any of the class specific features. The dividers are fixed in my application.
Instead I used NSStackView to encapsulate my subviews - and it works perfectly. (Hide and show subviews)

How to force an NSWindow to be in front of every app? Even fullscreen apps

I have an NSWindow that i would like to have it in front of everything (every app of the computer, fullscreen apps, etc..). Even if i click in a background app, the NSWindow cant go to background. And the NSWindow must follow the user screen if, for example, the user switches the desktop to desktop2, and so on...
How can i do that?
Thanks!
If you don't need to be visible with other apps' full-screen windows, it's not too hard.
First, to stay in front of everything else, just setLevel: with NSFloatingWindowLevel or higher. Experiment with the different values to see which seems appropriate to your needs.
Next, to stay in front even when the user changes Spaces, possibly including Exposé/Mission Control, setCollectionBehavior: with the appropriate pair of flags, or use the corresponding Spaces and Exposé settings in the Attributes Inspector if you're creating the window in the nib. Either Can Join All Spaces or Move to Active Space will make sure you stay visible on every space, in slightly different ways. You'll probably want Exposé set to Stationary, or possibly Transient, too. Again, try both ways and see.
However, Lion will hide both all-spaces and move-to-active-space windows when the user switches to a full-screen space or to Dashboard or Launchpad. And if you watch, you'll see that it does this in different ways for each of the three cases. And that Snow Leopard does things a little differently, and so does Mountain Lion.
If you want to solve that last problem, you need a bit of hackery—and different forms of hackery for each case and for each OS version. The basic trick is to catch the hide-related notifications and unhide yourself at the appropriate time.
You should modify your info.plist and set the Application is Agent flag to YES. An agent's window can be displayed in front of fullscreen windows.
Setting both,
"Application is agent (UIElement)" to "YES" in info.plist
&
window level :
self.view.window?.level = NSWindow.Level(rawValue: kCGMainMenuWindowLevel.hashValue - 1)
self.view.window?.collectionBehavior = [.stationary, .canJoinAllSpaces, .fullScreenAuxiliary]
helped me.

Applescript and Cocoa window positions

I know that using Applescript I can change the size and position of any application's window, but is it possible to get a notification whenever a window has changed it size or position?
If thats not possible, then what I was thinking was making a thread in the background, and constantly check the positions of windows and see if they have changed, if they did then they moved.
But that would take a lot of cpu resources to constantly compare the positions/sizes of window. So is it possible? If not , is there a better way? Thanks!
I'm not sure but i think there isn't a notification for that.
I would listen for mouse events. When the mouse was dragged you can check the windoews for changes. Hope that helpa.

Getting and setting the size of any window visible on screen

I'd like to be able to select (with the mouse), some window that's visible on the screen, store it's size. I also want to be able to modify the size of some window that's visible on the screen. The window is not a window within my own app.
How can I do this in Cocoa?
You can use the Accessibility API to control other apps' windows (and more).
I don't know how you can interface with windows in other applications. You would probably have to do something with Apple Script which can be run from Cocoa. As far as in your own app you can look at the documentation for NSWindow at Apples Site. You can get the window size with the frame property like [window frame] and save that either in mememory as an NSRect or if you need to save it in a file with NSNumbers or NSData. You can then resize a window by setting its frame property. with [window setFrame:] good luck hopefully this well get you in the right direction!

How do I use an indeterminate status indicator as the image for an NSStatusItem?

I have an application that is an NSStatusItem.
It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen.
I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X.
Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator?) or must I manually display an animation by cycling through a set of images?
In either case, how would I implement?
In order to have it be animated (and not just a static image), you'll probably need to use -setView: and give it a custom view (which then animates itself). You might be able to get away with using a suitably-configured standard NSProgressIndicator (i.e. set to NSProgressIndicatorSpinningStyle style, etc.) as that "custom view".
But, if the NSProgressIndicator standard sizes don't work well, then you can check out my YRKSpinningProgressIndicator (BSD-licensed), which is a clone of the spinning NSProgressIndicator that can be set to arbitrary size and colors.