c# 免注冊調用大漠插件100%完美識別文字
下載:https://download.csdn.net/download/xxq931123/10875122
綁定 模式:http://zy.anjian.com/?action-viewthread-tid-239647
test 發QQ消息:
public MainForm() { InitializeComponent(); dm = new CDmSoft(""); this.WindowState = FormWindowState.Minimized; // this.StartPosition = FormStartPosition.CenterScreen; } CDmSoft dm; private void MainForm_Load(object sender, EventArgs e) { int hwd = dm.FindWindow("TXGuiFoundation", "");//CabinetWClass Text = "" + hwd; if (hwd > 0) { int dm_ret = dm.BindWindowEx(hwd, "gdi", "windows", "windows", "dx.public.fake.window.min", 0); System.Threading.Thread.Sleep(1000); if (dm_ret == 0) { MessageBox.Show("failed"); return; } // MessageBox.Show( dm.GetWindowTitle(hwd)); dm.MoveWindow(hwd, 1, 1); // System.Threading.Thread.Sleep(2000); dm.SetWindowSize(hwd, 694,615); //dm.SetWindowText(hwd, "hello"); dm.MoveTo(113, 263); dm.LeftClick(); dm.delay(1000); dm.MoveTo(467, 540); dm.LeftClick(); Thread.Sleep(50); dm.SetWindowState(hwd, 1);//激活窗口 dm.SetWindowState(hwd, 8); Thread.Sleep(50); dm.SendString2(hwd, "hello你好"); Thread.Sleep(200); dm.KeyDown(13);//ENTER dm.KeyUp(13); dm.SetWindowState(hwd, 9);//設置為非活動窗口 //dm.SetWindowState(hwd, 2);//最小化 dm.UnBindWindow();//解綁窗口 } else { MessageBox.Show("can not find window"); } } }
查找微信和QQ的聊天窗口,根據窗口類名來進行模糊查找,然后得到窗口句柄,根據窗口句柄得到窗口的標題、類名信息(QQ聊天窗口的類名是:TXGuiFoundation,微信的聊天窗口類名是:ChatWnd):
var list = new List<int>(); list.AddRange(_dmsoft.EnumWindow(0, "", "TXGuiFoundation", 18).Split(',').Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => Convert.ToInt32(x))); list.AddRange(_dmsoft.EnumWindow(0, "", "ChatWnd", 18).Split(',').Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => Convert.ToInt32(x))); windInfoBindingSource.DataSource = list.Select(x => new WindInfo() { Handle = x, ClassName = _dmsoft.GetWindowClass(x), Title = _dmsoft.GetWindowTitle(x), }).ToList();
或者枚舉所有窗口:
int hwd = dm.FindWindow("TXGuiFoundation", "");//CabinetWClass List<WindowInfo> listWindows = new List<WindowInfo>(); string[] sList = dm.EnumWindow(0, "", "TXGuiFoundation", 18).Split(',');//.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => Convert.ToInt32(x))); foreach (string s in sList) { if (!string.IsNullOrEmpty(s)) { hwd = Convert.ToInt32(s); WindowInfo wd = new WindowInfo(); wd.ClassName = dm.GetWindowClass(hwd); wd.Handle=hwd; wd.Title= dm.GetWindowTitle(hwd); listWindows.Add(wd); } }
public class WindowInfo {
public int Handle;
public string ClassName;
public string Title;
}
普通窗口不用激活、設置前置窗口也能模擬 dm_bindRet = dm.BindWindowEx(hwd, "gdi", "windows3", "windows", "dx.public.fake.window.min", 0);
最后說下大漠缺點就是容易報毒。。。。。。。。。。。。
能考大漠API:https://www.cnblogs.com/xiongyunsheng/p/11254333.html