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

大漠插件:3.1233

找图,找色,识字,找字,窗口,按鼠标,按键盘

0、注册dm.dll;

regsvr32 xxx\dm.dll

1、添加com引用;

调用大漠插件发送QQ和微信消息 C#版_第1张图片

2、dmsoft各种调用;

原理:

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

截图:

调用大漠插件发送QQ和微信消息 C#版_第2张图片

 

代码:

 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     }

 

你可能感兴趣的:(调用大漠插件发送QQ和微信消息 C#版)