Get NSWindow from kCGWindowNumber

帅比萌擦擦* 提交于 2019-12-10 12:44:46

问题


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?


回答1:


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:.



来源:https://stackoverflow.com/questions/7587028/get-nswindow-from-kcgwindownumber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!