欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

调用大漠插件发送QQ和微信消息

程序员文章站 2022-06-05 18:54:13
大漠插件:3.1233 0、注册dm.dll; regsvr32 xxx\dm.dll 1、添加com引用; 2、dmsoft各种调用; 原理: 查找窗口hwnd→窗口激活→添加消息到文本框→回车→窗口取消激活 截图: 代码: ......

0、注册dm.dll;

regsvr32 xxx\dm.dll

1、添加com引用;

调用大漠插件发送QQ和微信消息

2、dmsoft各种调用;

原理:

查找窗口hwnd→窗口激活→添加消息到文本框→回车→窗口取消激活

截图:

调用大漠插件发送QQ和微信消息

 

代码:

 1 class form1 : form
 2     {
 3         public form1()
 4         {
 5             var dm = new dmsoft();
 6             console.writeline($"大漠插件{dm.ver()}");
 7             console.writeline($"{application.productname}-{application.productversion}");
 8 
 9             clientsize = new size(600, 400);
10             maximizebox = false;
11             formborderstyle = formborderstyle.fixedsingle;
12 
13             var listview1 = new listview() {name = "lstview1", location = new point(0, 0), size = new size(300, this.clientrectangle.height), columns = {"句柄", "标题", "类名"}, backcolor = color.cornsilk, fullrowselect = true, gridlines = true, view = view.details, checkboxes = true, multiselect = true,};
14             var btnreload = new button() {name = "btnreload", text = "刷新(&r)", location = new point(300, 3), autosize = true};
15             var btnsend = new button() {name = "btnsend", text = "发送(&s)", location = new point(400, 3), autosize = true};
16             var txtmessage = new textbox() {name = "txtmessage", text = "hello world!", location = new point(300, 30), size = new size(this.width - 300, clientrectangle.height - 30), multiline = true};
17             this.controls.addrange(new control[] {listview1, btnreload, btnsend, txtmessage});
18             this.text = $"{productname}-{productversion}";
19 
20             btnreload.click += (sender, args) =>
21             {
22                 var hwnds = new list<int>();
23                 var classnames = "txguifoundation,chatwnd".split(',');
24                 foreach (var classname in classnames)
25                 {
26                     var win = dm.enumwindow(0, "", classname, 18);
27                     hwnds.addrange(win.split(',').where(x => !string.isnullorempty(x)).select(x => convert.toint32(x)));
28                 }
29 
30                 listview1.beginupdate();
31                 listview1.items.clear();
32                 foreach (var hwnd in hwnds)
33                 {
34                     listview1.items.add(hwnd.tostring()).subitems
35                         .addrange(new string[] {dm.getwindowtitle(hwnd), dm.getwindowclass(hwnd)});
36                 }
37 
38                 listview1.endupdate();
39             };
40             btnsend.click += (sender, args) =>
41             {
42                 var msg = txtmessage.text;
43                 foreach (listviewitem item in listview1.checkeditems)
44                 {
45                     var hwnd = convert.toint32(item.text);
46                     console.writeline($"sendmessage to {item.subitems[0].text}");
47                     dm.bindwindowex(hwnd, "gdi", "windows", "windows", "", 0);
48                     dm.setwindowstate(hwnd, 1);
49                     dm.setwindowstate(hwnd, 8);
50                     dm.sendstring2(hwnd, msg);
51                     dm.keydown(13);
52                     dm.keyup(13);
53                     dm.setwindowstate(hwnd, 9);
54                     dm.setwindowstate(hwnd, 2);
55                     dm.unbindwindow();
56                 }
57             };
58             this.load += (sender, args) => { btnreload.performclick(); };
59         }
60     }