大漠插件是一個很不錯的東西,在按鍵精靈和易語言裏面用得不少,能夠後臺找圖找字,寫遊戲自動腳本用得特別多。前面寫一個微信的自動腳本,查了一些資料,易語言不太熟悉,按鍵精靈功能上可能很差實現,就找了些資料,大漠插件是能夠用在C#裏的調用的。這裏分享下方法。
1、引用Ddm.dll .NET裏面能夠直接引用,引用方法,添加引用--COM--找到DM,雙擊便可 2、註冊大漠插件
//這是註冊DLL到系統的一個方法,註冊大漠則調用 AutoRegCom("regsvr32 -s dm.dll"); static string AutoRegCom(string strCmd) { string rInfo; try { Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("cmd.exe"); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.CreateNoWindow = true; myProcessStartInfo.RedirectStandardOutput = true; myProcess.StartInfo = myProcessStartInfo; myProcessStartInfo.Arguments = "/c " + strCmd; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; rInfo = myStreamReader.ReadToEnd(); myProcess.Close(); rInfo = strCmd + "\r\n" + rInfo; return rInfo; } catch (Exception ex) { return ex.Message; } }
3、實例化大漠對象
Dm.dmsoft dm = new Dm.dmsoft();
4、調用大漠的方法 直接經過實例化的對象dm調用,如dm.MoveTo(30, 30); 完整代碼: 窗體上放一個按鈕,點擊按鈕,調用大漠插件將鼠標移動到(30,30)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.IO; namespace Player { public partial class Player : Form { public Player() { InitializeComponent(); AutoRegCom("regsvr32 -s dm.dll"); } private void button1_Click(object sender, EventArgs e) { Dm.dmsoft dm = new Dm.dmsoft(); dm.MoveTo(30, 30); } static string AutoRegCom(string strCmd) { string rInfo; try { Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("cmd.exe"); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.CreateNoWindow = true; myProcessStartInfo.RedirectStandardOutput = true; myProcess.StartInfo = myProcessStartInfo; myProcessStartInfo.Arguments = "/c " + strCmd; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; rInfo = myStreamReader.ReadToEnd(); myProcess.Close(); rInfo = strCmd + "\r\n" + rInfo; return rInfo; } catch (Exception ex) { return ex.Message; } } } }