QQ机器人(转贴)

这个元旦假期过的比较奇怪,为了向远方的GF表示忠诚。除了1号和同学吃了个大锅饭之外,尽量做到了大门不出二门不迈,躲在闺房守岁:)。
     在家闲着也不能干闲着,总得做点事情,想起前段时间一个师兄交代给我的任务:把若干个qq群串在一起。X国的政策一向比较Bt,你说开个群还要限制人数。H大在深圳有几千校友,一个群怎么可能放的下那么多人。好多在tx工作的师兄,明确告诉:我买通tx的人是不大可能了,搞一个传话筒才是解决之道。
       事情虽小,但也着实麻烦。你说要去分析QQ具体数据包,万一哪天tx一高兴把数据给改了,或者接口开放了,也够我郁闷一壶的了。那就找个最简单的办法吧,左一顿baidu,又一顿google. “QQ接口”搜出来的结果绝大多数是关于tx qq的http接口,既然大家那么推崇,那我就从Http接口下手,于是把我以前写的AJAX给拆了,在把所谓的qq接口研究成果给鼓捣在一起,然后去webqq( http://webqq.qq.com)上大抢一遍,那家伙,天昏地暗,相当的&(&(。
      代码我是用script写的:
None.gif 1 // 异步AJAX会话类
None.gif
  2 if ( typeof (AjaxSession)  ==   ' undefined ' )
ExpandedBlockStart.gifContractedBlock.gif  3var AjaxSession 
=  function() dot.gif {
InBlock.gif  
4    
InBlock.gif  
5    //创建会话
InBlock.gif
  6    this.CreateSession = function()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
7    dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
8        if (window.ActiveXObject)dot.gif{  // IE
ExpandedSubBlockStart.gifContractedSubBlock.gif
  9            trydot.gif{    
InBlock.gif 
10                return new ActiveXObject('Microsoft.XMLHTTP');
ExpandedSubBlockStart.gifContractedSubBlock.gif 
11            }
catch(e)dot.gif{}
InBlock.gif 
12                
ExpandedSubBlockStart.gifContractedSubBlock.gif 
13            trydot.gif
InBlock.gif 
14                return new ActiveXObject('Msxml2.XMLHTTP');
ExpandedSubBlockStart.gifContractedSubBlock.gif 
15            }
catch(ee)dot.gif{}
ExpandedSubBlockStart.gifContractedSubBlock.gif 
16        }
elsedot.gif{                   //Mozilla, Safari
InBlock.gif
 17            var s = new XMLHttpRequest(); 
ExpandedSubBlockStart.gifContractedSubBlock.gif 
18            if (s.readyState == nulldot.gif{
InBlock.gif 
19                s.readyState = 1;
ExpandedSubBlockStart.gifContractedSubBlock.gif 
20                s.addEventListener("load", function () dot.gif{
InBlock.gif 
21                    s.readyState = 4;
InBlock.gif 
22                    if (typeof(s.onreadystatechange) == "function")
InBlock.gif 
23                        s.onreadystatechange();
ExpandedSubBlockEnd.gif 
24                }
false);
ExpandedSubBlockEnd.gif 
25            }

InBlock.gif 
26            
InBlock.gif 
27            return s;
ExpandedSubBlockEnd.gif 
28        }

InBlock.gif 
29                    
InBlock.gif 
30        return null;
ExpandedSubBlockEnd.gif 
31    }

InBlock.gif 
32    
InBlock.gif 
33    //进行请求
InBlock.gif
 34    this.Request = function(url, params, callback)
ExpandedSubBlockStart.gifContractedSubBlock.gif 
35    dot.gif{    
InBlock.gif 
36        
InBlock.gif 
37        var s = this.CreateSession();
InBlock.gif 
38        if(null == s)
InBlock.gif 
39            alert("对不起,您的浏览器不支持某些特性。");
InBlock.gif 
40        else
InBlock.gif 
41            s.abort();
InBlock.gif 
42        
InBlock.gif 
43        var isAsync =  typeof(callback) == 'function';
InBlock.gif 
44        var method = !params ? "GET" : "POST";
InBlock.gif 
45
InBlock.gif 
46        if(isAsync) s.onreadystatechange = function()
ExpandedSubBlockStart.gifContractedSubBlock.gif 
47        dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif 
48            trydot.gif{
InBlock.gif 
49                alert(s.status);
InBlock.gif 
50                if ((4 == s.readyState) && (200 == s.status || 304 == s.status))
InBlock.gif 
51                    callback(this.Response(s));
InBlock.gif 
52                else
InBlock.gif 
53                    alert("请求错误,错误原因:" + s.statusText);    
ExpandedSubBlockStart.gifContractedSubBlock.gif 
54            }
catch(e)dot.gif{}
ExpandedSubBlockEnd.gif 
55        }

InBlock.gif 
56                
InBlock.gif 
57        s.open(method, url, isAsync);        
InBlock.gif 
58        s.setRequestHeader("Connection","Keep-Alive");        
InBlock.gif 
59        s.setRequestHeader("Content-Type","text/html; charset=gb2312");
InBlock.gif 
60        //s.setRequestHeader("Content-Type","text/plain; charset=UTF-8");
InBlock.gif
 61        
InBlock.gif 
62        if(method == "POST")
ExpandedSubBlockStart.gifContractedSubBlock.gif 
63        dot.gif{
InBlock.gif 
64            s.setRequestHeader("Content-Length",params.length)
InBlock.gif 
65            s.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
InBlock.gif 
66            
ExpandedSubBlockEnd.gif 
67        }

InBlock.gif 
68
InBlock.gif 
69        alert(params);
InBlock.gif 
70        s.send(params);
InBlock.gif 
71        
InBlock.gif 
72            
InBlock.gif 
73        if(!isAsync)
InBlock.gif 
74            return  this.Response(s);
ExpandedSubBlockEnd.gif 
75    }

InBlock.gif 
76    
InBlock.gif 
77    //返回应答信息
InBlock.gif
 78    this.Response = function(s)
ExpandedSubBlockStart.gifContractedSubBlock.gif 
79    dot.gif{
InBlock.gif 
80        if(s.status == 200  || 304 == s.status)
ExpandedSubBlockStart.gifContractedSubBlock.gif 
81        dot.gif{
InBlock.gif 
82            if(s.responseXML != null && s.responseXML.xml != null && s.responseXML.xml != '')
InBlock.gif 
83                return s.responseXML;
InBlock.gif 
84            else
InBlock.gif 
85                return s.responseText;
ExpandedSubBlockEnd.gif 
86        }
    
ExpandedSubBlockEnd.gif 
87    }

InBlock.gif 
88    
InBlock.gif 
89    //对字符串进行编码
InBlock.gif
 90    this.UncCoding = function(s) 
ExpandedSubBlockStart.gifContractedSubBlock.gif 
91    dot.gif{
InBlock.gif 
92        var output = '';
ExpandedSubBlockStart.gifContractedSubBlock.gif 
93        for(var i = 0 ;i< s.length;i++)dot.gif{
InBlock.gif 
94            output = output + '%' + s.charCodeAt(i);
ExpandedSubBlockEnd.gif 
95        }
        
InBlock.gif 
96
InBlock.gif 
97        return output; 
ExpandedSubBlockEnd.gif 
98    }

InBlock.gif 
99
InBlock.gif
100    //获取xml结构
ExpandedSubBlockStart.gifContractedSubBlock.gif
101    this.GetDom = function(s)dot.gif{
InBlock.gif
102        var doc = new ActiveXObject('Microsoft.XMLDOM'); 
InBlock.gif
103        doc.async = false;
InBlock.gif
104        doc.loadXML(s) ;    
InBlock.gif
105        return doc;
ExpandedSubBlockEnd.gif
106    }
 
InBlock.gif
107    
InBlock.gif
108    return this;
ExpandedBlockEnd.gif
109}


None.gif   1 // 会话类
None.gif
 2 if ( typeof (QQSession)  ==   ' undefined ' )
ExpandedBlockStart.gifContractedBlock.gif 3var QQSession 
=  function() dot.gif {
InBlock.gif 
4    this.UIN = 0;
InBlock.gif 
5    this.Md5PasswordStr = "";
InBlock.gif 
6    this.WebQQUrl = "http://tqq.tencent.com:8000/";
InBlock.gif 
7    this.qs = null;    
InBlock.gif 
8    this.isLogin = false
InBlock.gif 
9    this.SeqIndex = null;
InBlock.gif
10    
InBlock.gif
11    //用户登陆
ExpandedSubBlockStart.gifContractedSubBlock.gif
12    this.Login = function(uin,passwd,vcode,qs)dot.gif{
InBlock.gif
13        var m5 = new MD5();        
InBlock.gif
14        this.UIN = uin;        
InBlock.gif
15        this.Md5PasswordStr = m5.calcMD5(passwd);
InBlock.gif
16        var CmdStr = "VER=1.0&CMD=1&SEQ=" + this.GetNewSEQ() + "&UIN=" + uin + "&PS=" + this.Md5PasswordStr + "&STATUS=10&VCODE=" + vcode + "&QQSESSION=" + qs ;    
InBlock.gif
17        
InBlock.gif
18        //if(!this.qs)
InBlock.gif
19        //    this.qs = new AjaxSession();
InBlock.gif
20        window.frames["proxy"].request(this.WebQQUrl,CmdStr);
InBlock.gif
21        //this.qs.Request(this.WebQQUrl,CmdStr,this.ShowMsg);
InBlock.gif
22        
InBlock.gif
23        //document.getElementById("ssl_login").callback = this.ShowMsg;
InBlock.gif
24        //document.getElementById("ssl_login").src = "https://webqq-proxy.qq.com/webqq/l?"+ CmdStr;
ExpandedSubBlockEnd.gif
25    }

InBlock.gif
26    
InBlock.gif
27    //用户信息
ExpandedSubBlockStart.gifContractedSubBlock.gif
28    this.GetInfo = function()dot.gif{
InBlock.gif
29        var CmdStr = "VER=1.0&CMD=10&SEQ=" + this.GetNewSEQ() + "&UIN=" + this.UIN + "&FUIN=" + this.UIN;
InBlock.gif
30        this.qs.Request(this.WebQQUrl,CmdStr,this.ShowMsg);    
InBlock.gif
31        //window.frames["proxy"].request(this.WebQQUrl,CmdStr);
ExpandedSubBlockEnd.gif
32    }

InBlock.gif
33    
InBlock.gif
34    //获取好友列表
ExpandedSubBlockStart.gifContractedSubBlock.gif
35    this.GetList = function()dot.gif{
InBlock.gif
36        var CmdStr = "VER=1.0&CMD=2&SEQ=" + this.GetNewSEQ() + "&UIN=" + this.UIN + "&NPOS=0";
InBlock.gif
37        this.qs.Request(this.WebQQUrl,CmdStr,this.ShowMsg);    
ExpandedSubBlockEnd.gif
38    }

InBlock.gif
39    
InBlock.gif
40    //获得新的SEQ
ExpandedSubBlockStart.gifContractedSubBlock.gif
41    this.GetNewSEQ = function()dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
42        if(!this.SeqIndex)dot.gif{
InBlock.gif
43            var d = new Date();
InBlock.gif
44            this.SeqIndex = d.getTime()
ExpandedSubBlockEnd.gif
45        }

InBlock.gif
46        
InBlock.gif
47        this.SeqIndex ++;
InBlock.gif
48        return this.SeqIndex;        
ExpandedSubBlockEnd.gif
49    }

InBlock.gif
50    
ExpandedSubBlockStart.gifContractedSubBlock.gif
51    this.ShowMsg = function(s)dot.gif{
InBlock.gif
52        alert(s);
ExpandedSubBlockEnd.gif
53    }

InBlock.gif
54    
InBlock.gif
55    return this;
ExpandedBlockEnd.gif
56}

    我在那用天真的眼神,盼望着能从这个地方掏出点东西来。可偏偏我这个比较倒霉的孩子,碰到了极其复杂的网络问题(家穷人丑,只好用手机上网,速度回到上世纪90年代),掏了半天啥也没弄到,返回的尽是12152错误。
     去翻MSDN时,遇到几个头疼的单词(鄙人英语着实差劲,单词量屈指可数),很习惯的就去开金山词霸。等等,金山词霸能把别的窗口的信息给拽出来,为什么我就不能。于是我就抛弃了前面的工作,从QQ对话窗口下手。nndx,偶就不信了,偶还灭不了你。
  说干就干,那就先勾吧,.net好象是干不了这事,但是winapi还是能干这活的。win32编程嘛,不就几个消息循环(—(—……*(—
  
None.gif   1 using  System;
None.gif  2
using  System.Drawing;
None.gif  3
using  System.Runtime.InteropServices;
None.gif  
4
None.gif  5
namespace  TQQ
ExpandedBlockStart.gifContractedBlock.gif  
6 dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif  
7    /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif  8    /**//// WinApi调用
ExpandedSubBlockStart.gifContractedSubBlock.gif  9    /**//// </summary>
InBlock.gif 10    public class WinApi
ExpandedSubBlockStart.gifContractedSubBlock.gif 
11    dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif 
12        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 13        /**//// 根据鼠标位置获取窗体
ExpandedSubBlockStart.gifContractedSubBlock.gif 14        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 15        /**//// <param name="lpPoint"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 16        /**//// <returns></returns>
InBlock.gif 17        [DllImport("user32.dll")]
InBlock.gif 
18        public static extern IntPtr WindowFromPoint(Point lpPoint);
InBlock.gif 
19
ExpandedSubBlockStart.gifContractedSubBlock.gif 
20        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 21        /**//// 获取鼠标位置
ExpandedSubBlockStart.gifContractedSubBlock.gif 22        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 23        /**//// <param name="lpPoint"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 24        /**//// <returns></returns>
InBlock.gif 25        [DllImport("user32.dll")]
InBlock.gif 
26        public static extern int GetCursorPos(out Point lpPoint);
InBlock.gif 
27
ExpandedSubBlockStart.gifContractedSubBlock.gif 
28        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 29        /**//// 获取鼠标位置下的窗体
ExpandedSubBlockStart.gifContractedSubBlock.gif 30        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 31        /**//// <returns></returns>
InBlock.gif 32        public static IntPtr GetLocalWindow()
ExpandedSubBlockStart.gifContractedSubBlock.gif 
33        dot.gif{
InBlock.gif 
34            Point point;
InBlock.gif 
35            GetCursorPos(out point);
InBlock.gif 
36            return WindowFromPoint(point);
ExpandedSubBlockEnd.gif 
37        }

InBlock.gif 
38
ExpandedSubBlockStart.gifContractedSubBlock.gif 
39        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 40        /**//// 申请内存空间
ExpandedSubBlockStart.gifContractedSubBlock.gif 41        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 42        /**//// <param name="hProcess"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 43        /**//// <param name="lpAddress"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 44        /**//// <param name="dwSize"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 45        /**//// <param name="flAllocationType"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 46        /**//// <param name="flProtect"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 47        /**//// <returns></returns>
InBlock.gif 48        [ DllImport( "Kernel32.dll" )]
InBlock.gif 
49        public static extern Int32 VirtualAllocEx(IntPtr hProcess,Int32 lpAddress,Int32 dwSize,Int16 flAllocationType,Int16 flProtect);
InBlock.gif 
50
ExpandedSubBlockStart.gifContractedSubBlock.gif 
51        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 52        /**//// 读取内存空间
ExpandedSubBlockStart.gifContractedSubBlock.gif 53        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 54        /**//// <param name="hProcess"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 55        /**//// <param name="lpBaseAddress"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 56        /**//// <param name="lpBuffer"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 57        /**//// <param name="nSize"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 58        /**//// <param name="lpNumberOfBytesWritten"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 59        /**//// <returns></returns>
InBlock.gif 60        [ DllImport( "Kernel32.dll" )]
InBlock.gif 
61        public static extern int ReadProcessMemory(IntPtr hProcess, Int32 lpBaseAddress,byte[] lpBuffer,long nSize,long lpNumberOfBytesWritten);
InBlock.gif 
62
ExpandedSubBlockStart.gifContractedSubBlock.gif 
63        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 64        /**//// 写内存空间
ExpandedSubBlockStart.gifContractedSubBlock.gif 65        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 66        /**//// <param name="hProcess"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 67        /**//// <param name="lpBaseAddress"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 68        /**//// <param name="lpBuffer"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 69        /**//// <param name="nSize"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 70        /**//// <param name="lpNumberOfBytesWritten"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 71        /**//// <returns></returns>
InBlock.gif 72        [ DllImport( "Kernel32.dll" )]
InBlock.gif 
73        public static extern int WriteProcessMemory(IntPtr hProcess, Int32 lpBaseAddress,byte[] lpBuffer,long nSize,long lpNumberOfBytesWritten);
InBlock.gif 
74
ExpandedSubBlockStart.gifContractedSubBlock.gif 
75        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 76        /**//// 根据类/标题查找窗口
ExpandedSubBlockStart.gifContractedSubBlock.gif 77        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 78        /**//// <param name="lpClassName"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 79        /**//// <param name="lpWindowName"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 80        /**//// <returns></returns>
InBlock.gif 81        [DllImport("User32.dll",EntryPoint="FindWindow")]
InBlock.gif 
82        public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
InBlock.gif 
83
ExpandedSubBlockStart.gifContractedSubBlock.gif 
84        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 85        /**//// 获取窗口子对象
ExpandedSubBlockStart.gifContractedSubBlock.gif 86        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 87        /**//// <param name="hwndParent"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 88        /**//// <param name="hwndChildAfter"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 89        /**//// <param name="lpszClass"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 90        /**//// <param name="lpszWindow"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 91        /**//// <returns></returns>
InBlock.gif 92        [DllImport("user32.dll",EntryPoint="FindWindowEx")]
InBlock.gif 
93        public static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
InBlock.gif 
94
ExpandedSubBlockStart.gifContractedSubBlock.gif 
95        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 96        /**//// 发送windows消息
ExpandedSubBlockStart.gifContractedSubBlock.gif 97        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif 98        /**//// <param name="hWnd"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif 99        /**//// <param name="Msg"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif100        /**//// <param name="wParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif101        /**//// <param name="lParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif102        /**//// <returns></returns>
InBlock.gif103        [DllImport("User32.dll")]
InBlock.gif
104        public static extern IntPtr SendMessage(IntPtr hWnd,int Msg,IntPtr wParam,IntPtr lParam);
InBlock.gif
105
ExpandedSubBlockStart.gifContractedSubBlock.gif
106        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif107        /**//// 发送windows消息
ExpandedSubBlockStart.gifContractedSubBlock.gif108        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif109        /**//// <param name="hWnd"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif110        /**//// <param name="Msg"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif111        /**//// <param name="wParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif112        /**//// <param name="lParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif113        /**//// <returns></returns>
InBlock.gif114        [DllImport("User32.dll",EntryPoint="SendMessage")]
InBlock.gif
115        public static extern int SendMessage(IntPtr hWnd,int Msg, IntPtr wParam, string lParam);
InBlock.gif
116
ExpandedSubBlockStart.gifContractedSubBlock.gif
117        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif118        /**//// 发送windows消息
ExpandedSubBlockStart.gifContractedSubBlock.gif119        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif120        /**//// <param name="hwnd"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif121        /**//// <param name="wMsg"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif122        /**//// <param name="wParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif123        /**//// <param name="lParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif124        /**//// <returns></returns>
InBlock.gif125        [DllImport("user32.dll", CharSet = CharSet.Auto)]
InBlock.gif
126        public static extern int SendMessage( IntPtr hwnd, int wMsg, int wParam,string lParam);
InBlock.gif
127
ExpandedSubBlockStart.gifContractedSubBlock.gif
128        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif129        /**//// 发送windows消息
ExpandedSubBlockStart.gifContractedSubBlock.gif130        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif131        /**//// <param name="hwnd"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif132        /**//// <param name="wMsg"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif133        /**//// <param name="wParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif134        /**//// <param name="lParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif135        /**//// <returns></returns>
InBlock.gif136        [DllImport("user32.dll", CharSet = CharSet.Auto)]
InBlock.gif
137        public static extern int SendMessage( IntPtr hwnd, int wMsg, int wParam,int lParam);
InBlock.gif
138
ExpandedSubBlockStart.gifContractedSubBlock.gif
139        /**//**//**//// <summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif140        /**//// 发送windows消息
ExpandedSubBlockStart.gifContractedSubBlock.gif141        /**//// </summary>
ExpandedSubBlockStart.gifContractedSubBlock.gif142        /**//// <param name="hwnd"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif143        /**//// <param name="wMsg"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif144        /**//// <param name="wParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif145        /**//// <param name="lParam"></param>
ExpandedSubBlockStart.gifContractedSubBlock.gif146        /**//// <returns></returns>
InBlock.gif147        [DllImport("user32.dll", CharSet = CharSet.Auto)]
InBlock.gif
148        public static extern int SendMessage( IntPtr hwnd, int wMsg, int wParam,System.Text.StringBuilder lParam);
InBlock.gif
149
InBlock.gif
150        public const int WM_GETTEXT = 0x000D;
InBlock.gif
151        public const int WM_GETTEXTLENGTH = 0x000E;
InBlock.gif
152        public const int WM_SETTEXT = 0x000C;
InBlock.gif
153        public const int WM_CLICK = 0x00F5;
InBlock.gif
154        public const int WM_CHAR = 0x0102;
InBlock.gif
155        public const int EM_SETSEL = 0x00B1;
InBlock.gif
156        public const int EM_REPLACESEL = 0x00C2;
InBlock.gif
157
ExpandedSubBlockEnd.gif
158    }

ExpandedBlockEnd.gif
159}

东西到手了,传话筒的工作基本上算是完成了,接下来就让它显示出来:

ExpandedBlockStart.gif ContractedBlock.gif   1      /**/ /**/ /**/ /// <summary>
ExpandedBlockStart.gif ContractedBlock.gif   2          /**/ /// 时钟事件
ExpandedBlockStart.gif ContractedBlock.gif   3          /**/ /// </summary>
ExpandedBlockStart.gif ContractedBlock.gif   4          /**/ /// <param name="sender"></param>
ExpandedBlockStart.gif ContractedBlock.gif   5          /**/ /// <param name="e"></param>
None.gif   6          private   void  tmGetMsg_Tick( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif 
7          dot.gif {
InBlock.gif 
8            //群1里的消息
InBlock.gif
 9            string strMsg = QQHooks.GetMsg(txtGroupWinName1.Text);        
InBlock.gif
10            string str = "";
InBlock.gif
11            
InBlock.gif
12            if(!string.Empty.Equals(strMsg))
ExpandedSubBlockStart.gifContractedSubBlock.gif
13            dot.gif{
InBlock.gif
14                ArrayList msgList = ParseMsg.Parse(strMsg);
InBlock.gif
15
InBlock.gif
16                foreach(QQMsg msg in msgList)
ExpandedSubBlockStart.gifContractedSubBlock.gif
17                dot.gif{
InBlock.gif
18                    if("253822559" == msg.Number.ToString())continue;
InBlock.gif
19                    
InBlock.gif
20                    if(string.Empty.Equals(msg.Msg.Trim()))
InBlock.gif
21                        str =  string.Format("{0}在群1里做了个表情\r\n",msg.Name,msg.Msg);
InBlock.gif
22                    else
InBlock.gif
23                         str =  string.Format("{0}在群1里说:\r\n{1}\r\n",msg.Name,msg.Msg);
InBlock.gif
24                    
InBlock.gif
25                    lbGroupMsgList1.Items.Add(str);
InBlock.gif
26                    //save msg 
InBlock.gif
27                    
InBlock.gif
28                    //发送消息
InBlock.gif
29                    QQHooks.SendMsg(txtGroupWinName2.Text,str);
InBlock.gif
30                    QQHooks.SendMsg(txtGroupWinName3.Text,str);
InBlock.gif
31                    
ExpandedSubBlockEnd.gif
32                }
                
ExpandedSubBlockEnd.gif
33            }

ExpandedBlockEnd.gif
34  }

这里的txtGroupWinName1是让输入qq窗口标题。以前用asm32做程序的时候就觉的微软够BT的,要是每个窗口编译的时候就给限制个GUID多好—()—*)((—
至此大功算是告成了,完美交差。拿着这东东,改天狠狠的宰我师兄几顿.

(07-01-04)续:
要的人太多了,我还是主动把东西传上来吧,要不然有骗 email地址之嫌
源代码和相关资料下载:/Files/sukyboor/Q.rar

附,说明:先介绍一下http方法:
 1,qq接口.txt
   是我在网络上找的一篇“C#编写QQ接口软件--QQ协议篇” 里面有QQhttp协议访问的详细的介绍,协议标准是v1.1。但是经过我是没调通,好象是 http://tqq.tencent.com:8000被封了,你有没有好的运气我就不知道了。tx的webqq用的端口是 http://webqq-proxy.qq.com:8080/这个就是慢点,用还是能用的。
 2,Maxthon_Appin 文件夹下面有2个文件QQTest.txt ,GetQQSession.txt。maxthon有个简易收集面板你可以动态的去调试脚本.用maxthon打开 http://webqq.qq.com后装入qqtest.txt你会发现访问过程的一举一动都在你的监视之中。Log.txt就是这么来的。GetQQSession.txt操作同上,用于获取一个新的sessionid
 3,log.txt是监视 http://webqq.qq.com的访问过程后得来的.你可以参考qq接口.txt看。不过tx的webqq用的是v1.0的接口,但大体上是相似的,相信聪明的你是可以看懂的。
  4,webqq文件夹下放着 http://webqq.qq.com被我下到本地的页面。有兴趣的可以去看看里面的脚本,尤其是js\web_cmd.js虽然写的比我还烂,但还是值得一看。
 5,WQQ文件夹下放着我写的测试页面。不过我家的破电脑调不通。如果你运气好的话,在这个基础上继续干吧。不过别忘记了,到时候把做好的东西发给我一份(sukyboor·163.com)。
好了,下面说说钩子方法
  项目在TQQ文件夹下面,注释写的挺详细的,自己看吧。
就提醒4点,
 1 是app.config里面的qqnum一定要配置成你的qq号,否则你就等着别人骂你sx吧。
 2 主窗口上的几个输入框一定要配置成群聊窗口的标题,否则它啥也干不了
3 别告诉我你还用qq2005
 4 消息被转发以后在窗口里是看不到的,得点聊天记录按纽以后才能看的见
 
license.txt
  里面堆的是一堆套话,有空就瞅2眼.

转载于:https://www.cnblogs.com/shf/archive/2007/07/05/806707.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值