File: get-window-id.m

package info (click to toggle)
haskell-mode 17.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,596 kB
  • sloc: lisp: 21,482; makefile: 104; sh: 59; objc: 13
file content (15 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#include <Cocoa/Cocoa.h>
#include <CoreGraphics/CGWindow.h>

int main(int argc, char **argv)
{
    NSArray *windows = (NSArray *)CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements,kCGNullWindowID);
    for(NSDictionary *window in windows) {
        if ([[window objectForKey:(NSString *)kCGWindowOwnerPID] isEqual:[NSNumber numberWithLongLong:atoi(argv[1])]]) {
            if ([[window objectForKey:(NSString *)kCGWindowName] isEqual:[NSString stringWithUTF8String:argv[2]]]) {
                printf("%d\n", [[window objectForKey:(NSString *)kCGWindowNumber] intValue]);
            }
        }
    }
}