Is it possible to attach my window to a window of another application? - objective-c

On Windows we can find the window handle of running process and attach our window onto it as a child window, so the two different processes look like the same one.
I wonder if there is a similar way to implement this requirement in cocoa.

This is possible using code injection. Have a look at mach inject framework and PorcShark Finder.
Or
Find position of another window using CGWindow methods and display your window over it.
Have a look at Son of Grab sample project.
Son of Grab shows how to use the new CGWindow API to get images of arbitrary sets
of windows, including images of the current contents of the screen.

Related

How To get to know focussed window in cocoa, and how to set it to desired window.?

I am new to the cocoa mac development, Right now i am developing a mac app having several server hit after a particular time. If the hit gets desired data then I need to to show the equivalent window and to show the window i am using [myWindow showWindow:self] method. It shows desired window and set the key window to my visible window is that myWindow.
Each and everything is fine till now but the problem is that suppose when a user start working on any window and open several other child window then unfortunately my show window get called and the focus of my working window transferred to other window.
After several searches i found that i can get the focused window by accessing the [[NSApplication sharedApplication]keyWindow]delegate], I applied several condition that when my this and this window is on key window then don't hit server.
But the problem is not get solved. Now i think setting a keyWindow to my current working window will be best option.
Please suggest me what can i do and how i can forcefully set a window as my key window.
Any Help would be appreciated.
Thanks In advance.
If I understand your question correctly you wish to bring a window forward if it receives input from your server but without moving it in front of the current main or key windows.
The method you are using, showWindow:, belongs to NSWindowController and both shows a window and makes it key.
What you need to look at are the NSWindow methods for managing the window levels, orderFront: et al.
In particular you might want to use orderWindow:relativeTo: which allows to place a window in front/behind another window. For example:
[<window> orderWindow:NSWindowBelow
relativeTo:NSApp.keyWindow.windowNumber];
will move a window to be immediately behind the current key window, and in front of any other windows behind the key window.
HTH

getting position (x,y) , width and lenght of Lotus Notes window in vb.net

I'm trying to get the starting position (x,y), the width and the lenght of a Lotus Notes application window from a vb.net application.
so far, I've tried using Process to do the trick but I can't figure out what to use after finding the good process in windows running process list. The only "usefull" thing which use or see the UI is the Process.MainWindowTitle. It does give the title of my Notes Window but As I said, I want coordonates, width and lenght.
I also tried using back-end classes: COM object lotus and domino
But nothing in those have necessary stuff to fill my needs.
I would also need the state of the window, something like
SHOWNORMAL
HIDE
RESTORE
SHOWMAXIMIZED
SHOWMINIMIZED
...
EDIT
I want to get the position of the window to modify the position of my application. Also I want to resise and modify the position of the Notes client. My goal here is to make both of my application and the Notes client fit in the screen.
Any help is very apreaciated!
I did something like that using the Windows API some years ago. Right now, I got no examples about that, but what I did it was this: get the handler from Lotus Notes window, and then, get the handler from an embedded view, and simulate a click event to set the focus in it.
You can use the WinAPI, but that's not necessarily the best approach. You should consider other alternatives as Karl-Henry Martinsson says.

How can I make a copy of an already created window?

So I am making an xcode application for OS X, and so far things have gone well. However, right now I am at a roadblock. My app is mostly one window, and I need that window to be created multiple times, in the way that apps like Safari, TextEdit, and all those ones have the File>New function. I am new at Xcode, and I was wondering if there was an easy way (hopefully 3-4 lines of code) to do this. If someone could explain that to me that would be great.
Thanks!
Start a new OS X project and choose "Create Document Based Application" . This will create a NSDocument subclass.
If you want to use Core Data , choose that also. This will create a NSPersistentDocument subclass.
This will give you the basis of your application with all the functionality you ask for.
Have a look at Document Based App Programming guide and NSPersistentDocument Class Reference
Whatever you do, dont try to bake your own. There lies madness.
The project template sets up the info.plist correctly to make this work.
Whatever I tell you, it won't involve only "3-4 lines of code," unfortunately.
If you're working from a non-document-based application, you'll want to factor out the code that creates your one window. If you're not using a window controller in concert with your window, you should implement one. Then you can implement an action that will create a new instance of your window controller, and so a new window. Of course, you'll need to add more infrastructure if you're interested in saving information associated with a window to a file.
Which leads me to your other option, which is to create a document-based application. The big advantage here is that, if you're interested in saving the window contents to a file, the infrastructure for doing so is provided. This involves starting over to some extent, but since you've already got the guts of your application working, you'd simply transfer those guts to the document subclass that is provided for you. You'd also need to provide to your project meta information describing the kind of document it is, including the file extension describing it.
Best wishes to you in your endeavors.

Get live screenshot of window in objective-c

I'm trying to find a way to get a live view of a specific window. In the same way that Mission Control and Exposé will show you live views of windows that are currently obscured by other windows (this is also done by Hyperdock, so I'm pretty certain that its not a private API).
What is the functionality called? And so where is the documentation on it?
You want the Quartz Window Services API. Basically, you want to create a window list with the windows you're interested in and use CGWindowListCreateImage to get a picture of the window's contents.

Can you attach a drawer to another application in Cocoa?

Is there a way for one Cocoa application to attach drawer-like windows to another application? We might for example want a terminal drawer that followed around a particular Finder window.
There is a program called DTerm that opens little transparent windows over Finder windows, but one might prefer persistence.
You may want to checkout SIMBL. It allows you to write nifty bundles that are loaded into the application your targeting. If you go along with it I'd reccomend using class dump to gather more information on the application your working with (although Im not sure it would work with Finder)