Monday, November 01, 2010

MacRuby: Test 1

Get list of all visible windows from running apps.

framework 'cocoa'

=begin

enum {
kCGWindowListOptionAll = 0,
kCGWindowListOptionOnScreenOnly = (1 << 0),
kCGWindowListOptionOnScreenAboveWindow = (1 << 1),
kCGWindowListOptionOnScreenBelowWindow = (1 << 2),
kCGWindowListOptionIncludingWindow = (1 << 3),
kCGWindowListExcludeDesktopElements = (1 << 4)
}


=end

kCGWindowListOptionOnScreenOnly = (1<<4)
kCGNullWindowID = 0 #(CGWindowID)0


windowlist = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly,kCGNullWindowID)
n = 1
windowlist.each {| w |
p " #{n} #{w["kCGWindowOwnerName"]} "
p " #{w}"

w.each { |e| p " #{e} " }

p " ============================ " 
n += 1

}

No comments: