<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Xamarin.Mac%2F%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B</id>
	<title>Xamarin.Mac/ウインドウの一覧を取得する - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Xamarin.Mac%2F%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B"/>
	<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B&amp;action=history"/>
	<updated>2026-06-04T05:33:05Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B&amp;diff=7642&amp;oldid=prev</id>
		<title>111.188.1.57: /* 関連項目 */</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B&amp;diff=7642&amp;oldid=prev"/>
		<updated>2015-10-16T17:46:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;関連項目&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2015年10月16日 (金) 17:46時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l97&quot;&gt;97行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;97行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[Xamarin.Mac/アクセシビリティの許可の有無を取得する]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[Xamarin.Mac/アクセシビリティの許可の有無を取得する]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[Xamarin.Mac/OSのバージョンを取得する]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[Xamarin.Mac/OSのバージョンを取得する]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*[[Xamarin.Mac/スクリーンキャプチャを撮る]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==参考文献==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==参考文献==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>111.188.1.57</name></author>
	</entry>
	<entry>
		<id>https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B&amp;diff=7641&amp;oldid=prev</id>
		<title>153.219.225.170: ページの作成:「==概要== Mac OS X上で開いている全てのウインドウの情報を取得したい。  ==実装== Mac上で開いているウインドウの一覧を取...」</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%82%A6%E3%82%A4%E3%83%B3%E3%83%89%E3%82%A6%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B&amp;diff=7641&amp;oldid=prev"/>
		<updated>2015-10-16T07:41:15Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「==概要== &lt;a href=&quot;/wiki/Mac_OS_X&quot; title=&quot;Mac OS X&quot;&gt;Mac OS X&lt;/a&gt;上で開いている全てのウインドウの情報を取得したい。  ==実装== &lt;a href=&quot;/wiki/Mac&quot; title=&quot;Mac&quot;&gt;Mac&lt;/a&gt;上で開いているウインドウの一覧を取...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==概要==&lt;br /&gt;
[[Mac OS X]]上で開いている全てのウインドウの情報を取得したい。&lt;br /&gt;
&lt;br /&gt;
==実装==&lt;br /&gt;
[[Mac]]上で開いているウインドウの一覧を取得するには[[Core Graphics]]のCGWindowListCopyWindowInfoメソッドを呼び出してやることで実現できる。&lt;br /&gt;
&lt;br /&gt;
このメソッドをラッピングしたと思わしきクラスは2015年10月時点での[[Xamarin.Mac]]には見当たらない。&lt;br /&gt;
一方でこのメソッドの引数に渡すCGWindowListOption列挙体だけは標準で存在している。&lt;br /&gt;
仕方がないので[[P/Invoke]]で直叩きしてみた。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using MonoMac.Foundation;&lt;br /&gt;
using MonoMac.AppKit;&lt;br /&gt;
using MonoMac.CoreGraphics;&lt;br /&gt;
&lt;br /&gt;
public static class CoreGraphicsEx&lt;br /&gt;
{&lt;br /&gt;
    public const string DllName = &amp;quot;/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    [DllImport(DllName)]&lt;br /&gt;
    extern static IntPtr CGWindowListCopyWindowInfo(CGWindowListOption option, UInt32 relativeToWindow);&lt;br /&gt;
&lt;br /&gt;
    [DllImport(DllName)]&lt;br /&gt;
    extern static void CFRelease(IntPtr cf);&lt;br /&gt;
&lt;br /&gt;
    public static NSDictionary[] GetWindowList(CGWindowListOption option, UInt32 relativeToWindow = 0)&lt;br /&gt;
    {&lt;br /&gt;
        IntPtr handle = IntPtr.Zero;&lt;br /&gt;
&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            handle = CoreGraphicsEx.CGWindowListCopyWindowInfo(option, relativeToWindow);&lt;br /&gt;
            return NSArray.ArrayFromHandle&amp;lt;NSDictionary&amp;gt;(handle);&lt;br /&gt;
        }&lt;br /&gt;
        finally&lt;br /&gt;
        {&lt;br /&gt;
            if (handle != IntPtr.Zero)&lt;br /&gt;
            {&lt;br /&gt;
                CFRelease(handle);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        NSApplication.Init();&lt;br /&gt;
&lt;br /&gt;
        var windows = CoreGraphicsEx.GetWindowList(CGWindowListOption.All, 0);&lt;br /&gt;
        foreach (var window in windows)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(window.);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
上記の実装では以下のような構造（NSDictionary）の[[配列]]が得られる。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    kCGWindowAlpha = 1;&lt;br /&gt;
    kCGWindowBounds =     {&lt;br /&gt;
        Height = 291;&lt;br /&gt;
        Width = 1465;&lt;br /&gt;
        X = 1072;&lt;br /&gt;
        Y = 1126;&lt;br /&gt;
    };&lt;br /&gt;
    kCGWindowLayer = 0;&lt;br /&gt;
    kCGWindowMemoryUsage = 1717392;&lt;br /&gt;
    kCGWindowName = XamarinStudio;&lt;br /&gt;
    kCGWindowNumber = 1483;&lt;br /&gt;
    kCGWindowOwnerName = &amp;quot;Xamarin Studio&amp;quot;;&lt;br /&gt;
    kCGWindowOwnerPID = 28997;&lt;br /&gt;
    kCGWindowSharingState = 1;&lt;br /&gt;
    kCGWindowStoreType = 2;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
これは[[配列]]に[[連想配列]]が入っているような状態であり、各項目はアクセサメソッドで取得できる。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
    var windows = CoreGraphicsEx.GetWindowList(CGWindowListOption.All, 0);&lt;br /&gt;
    foreach (var window in windows)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(window[&amp;quot;kCGWindowOwnerPID&amp;quot;]);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==関連項目==&lt;br /&gt;
*[[Xamarin.Mac/CoreGraphicsの基本的な使い方]]&lt;br /&gt;
*[[Xamarin.Mac/スクリーンセーバーを終了させる]]&lt;br /&gt;
*[[Xamarin.Mac/キーボードの入力をシミュレートする]]&lt;br /&gt;
*[[Xamarin.Mac/アクセシビリティの設定変更を検知する]]&lt;br /&gt;
*[[Xamarin.Mac/アクセシビリティの許可の有無を取得する]]&lt;br /&gt;
*[[Xamarin.Mac/OSのバージョンを取得する]]&lt;br /&gt;
&lt;br /&gt;
==参考文献==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
{{stub}}&lt;br /&gt;
&lt;br /&gt;
[[category:Xamarin.Mac]]&lt;br /&gt;
[[category:MonoMac]]&lt;/div&gt;</summary>
		<author><name>153.219.225.170</name></author>
	</entry>
</feed>