c# api操作阿里旺旺的好友列表
我要操作阿里旺旺中的好友列表,例如打开指定好友的聊天对话框等,但是不知道为什么我往阿里旺旺好友列表里面SendMessage发送消息的时候返回值都是0 操作不成功,高手帮看看...C# code
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Management;
using System.Configuration.Install;
using System.ServiceProcess;
namespace alwwhelp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public const UInt32 TV_FIRST = 0x4352;
public const UInt32 TVGN_ROOT = 0x0000;
public const UInt32 TVM_GETNEXTITEM = TV_FIRST + 10;
public const UInt32 TVM_SETITEM = TV_FIRST + 13;
public const UInt32 WM_USER = 0x0400;
public const UInt32 TVM_SELECTITEM = WM_USER + 100;
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern UInt32 SendMessage(
IntPtr hWnd,
UInt32 Msg,
UInt32 wParam,
UInt32 lParam
);
#region Dll Import
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")] //找子窗体
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
#endregion
private void button2_Click(object sender, EventArgs e)
{
IntPtr hwndCalc = FindWindow(null, "qzu274-阿里旺旺2009"); //查找阿里旺旺的句柄 qzu274-阿里旺旺2009--阿里旺旺登录成功后窗口标题
IntPtr WorkingPage = new IntPtr(0); //阿里旺旺下的WorkingPage子窗体
IntPtr tabviewcontainer = new IntPtr(0); //WorkingPage下的子窗体tabviewcontainer
IntPtr contactlistpagecontainer = new IntPtr(0);//tabviewcontainer下的子窗体contactlistpagecontainer
IntPtr contactlistpage = new IntPtr(0); //contactlistpagecontainer下的子窗体contactlistpage
IntPtr gf = new IntPtr(0);//contactlistpage下的子窗体(好友窗体)
IntPtr listview = new IntPtr(0); //好友窗体下的树形窗体
if (hwndCalc != IntPtr.Zero)
{
WorkingPage = FindWindowEx(hwndCalc, WorkingPage, "StandardWindow", "WorkingPage"); //获取WorkingPage句柄
tabviewcontainer = FindWindowEx(WorkingPage, tabviewcontainer, "StandardWindow", "tabviewcontainer"); //获取tabviewcontainer句柄
contactlistpagecontainer = FindWindowEx(tabviewcontainer, contactlistpagecontainer, "StandardWindow", "contactlistpagecontainer"); //获取contactlistpagecontainer句柄
contactlistpage = FindWindowEx(contactlistpagecontainer, contactlistpage, "StandardWindow", "contactlistpage"); //获取contactlistpage句柄
gf = FindWindowEx(contactlistpage, gf, "StandardWindow", "好友"); //获取好友窗体句柄
listview = FindWindowEx(gf, listview, "WWUI.SuperListView", ""); //获取树形窗体句柄
if (listview != IntPtr.Zero)
{
MessageBox.Show(listview.ToString()); //查看用户listview的句柄,这里可以查看到listview的句柄
// 这里有问题,不知道为什么返回值是0
UInt32 rootHwnd = SendMessage(listview, TVM_GETNEXTITEM, TVGN_ROOT, 0x0);//获取树的根结点,也就是列表中第一个分类
MessageBox.Show(rootHwnd.ToString());
}
else
{
//未能获取句柄
}
}
}
}
}
我的思路是按照http://topic. 这里操作的,但是这里说阿里旺旺的好友控件是treeview 而我获得的阿里旺旺的好友控件却是“WWUI.SuperListView” ,请高手帮帮忙...