Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get NSWindow from kCGWindowNumber

From kCGWindowNumber, how do I get NSWindow ref. I tried using:

[NSApp windowWithWindowNumber:windowNumber]

but I always get a null value. I need to get the NSWindow to apply [window setlevel:NSFloatingWindowLevel], that I have set the always on top of a given window. Does anyone know how to solve this problem or has any alternative solution?


Thanks for the answer, but this is not the solution, I had already tried but it does not work, actually I did a test , I tried the following code:

for (NSInteger i = 0; i <10000; i + +) {
NSWindow * wind;
wind = [NSApp windowWithWindowNumber: windowNumber];
NSLog (@ "\ n Window:% @", wind);
}

but the result is always the Window: (null)

I have a list of window, where can i get OwnerPid Number of window ecc.. ecc... and now I need to set the always on top of some windows.

The Always on top is possible set whit: [window setlevel:NSFloatingWindowLevel], window is a NSwindow object, it's real?

Do you have a solution? or another idea , for my problem?

like image 661
Esse Avatar asked Sep 28 '11 17:09

Esse


1 Answers

kCGWindowNumber is a CFNumber/NSNumber, -windowWithWindowNumber: expects an NSInteger. You'll need to extract the integer out of the window number reference (with -integerValue) before passing it to -windowWithWindowNumber:.

like image 55
一二三 Avatar answered Oct 10 '22 03:10

一二三