1

Gtalk のステータス (オンライン/オフライン) を表示するプログラムを作成しようとしています。

代替テキスト

Status View 2 クラスは見つかりますが、その中のテキストを見つけるにはどうすればよいですか。

これが私のコードです。

API宣言:

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

Api を呼び出すコード:

IntPtr hwnd = IntPtr.Zero;

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Google Talk - Google Xmpp Client GUI Window", "Google Talk");

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Main View", "@main");

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Status View 2", "Status Box");

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "RichEdit20W", "String.Empty");

MessageBox.Show(hwnd.ToString());

ありがとう。

4

1 に答える 1

2

私は自分で解決策を見つけました。アバザバムに感謝します。

代替テキスト

図を見ると、クラス名が「#32770」でウィンドウキャプションが「Sign In Dialogue」のパネルがあります。

ユーザーがオフラインのときはこのパネルが表示され、ユーザーがオンラインになるとパネルは表示されません。

したがって、主なロジックは、パネルの可視性を検出することです。

Spy++ を使用してクラス名を見つけることができます。

代替テキスト

API宣言:

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool IsWindowVisible(IntPtr hWnd);

コード :

IntPtr hwnd = IntPtr.Zero;

bool check;

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Google Talk - Google Xmpp Client GUI Window", "Google Talk");

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Main View", "@main");

hwnd = FindWindowEx(hwnd, IntPtr.Zero, "#32770", "Sign In Dialogue");

check = IsWindowVisible(hwnd);

if (check == true)
{
     MessageBox.Show("User is offline.");
}
else
{
     MessageBox.Show("User is online.");
}

とにかく、私の問題を読んでくれてありがとう。

于 2010-06-27T20:35:38.963 に答える