最近因为工作上有一些重复的事情需要完成,所以就想着如何用脚本来实现重复的工作。
在网上找到了一个大漠插件(之前在易语言中有接触过,别问我什么是易语言)
大漠插件的介绍:
大漠综合插件(dm.dll)采用vc6.0编写,是一款集前后台,文字识别,图色,键鼠,窗口,内存,DX,Call等功能于一身的综合插件。主要用于按键精灵
、简单游、易语言等辅助制作工具,具有识别速度超级快的特点! 采用COM接口编写,适用于所有语言调用。
调用
//引用
using CShapDM;
//调用
CDmSoft dm = new CDmSoft();
讲一个例子:
我想实现后台对记事本写入文字
//做好了引用
//开始调用
CDmSoft dm = new CDmSoft();
//首先要想对记事本进行写入文字,首先得绑定句柄
//获取句柄 FindWindow("类名","名称")
int hwnd = dm.FindWindow("", "记事本.txt");
//调用大漠类的SendString2("句柄","写入的内容")方法。
dm.SendString2(hwnd,"2333");
大漠的类在下面,在DeBug下面还要放入一个大漠的dll文件。
在分享一个大漠说明和大漠工具,祝大家顺利~有问题回复解答。
大漠插件类:Cdmsoft
<span style="font-family: arial, 宋体, sans-serif;">using System;</span>
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace CShapDM
{
/// <summary>
/// 大漠插件C#免注册调用类
/// 本模块必须包含dmc.dll 实现不用注册dm.dll 到系统可以动态调用
/// </summary>
class CDmSoft : IDisposable
{
#region import DLL 函数
[DllImport("dmc.dll",CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr CreateDM(string dmpath);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FreeDM();
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string Ver(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetPath(IntPtr dm,string path);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string Ocr(IntPtr dm,int x1,int y1,int x2,int y2,string color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FindStr(IntPtr dm,int x1,int y1,int x2,int y2,string str,string color,double sim,out object x,out object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetResultCount(IntPtr dm,string str);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetResultPos(IntPtr dm,string str,int index,out object x,out object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int StrStr(IntPtr dm,string s,string str);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SendCommand(IntPtr dm,string cmd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int UseDict(IntPtr dm,int index);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetBasePath(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetDictPwd(IntPtr dm,string pwd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string OcrInFile(IntPtr dm,int x1,int y1,int x2,int y2,string pic_name,string color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int Capture(IntPtr dm,int x1,int y1,int x2,int y2,string file_);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int KeyPress(IntPtr dm,int vk);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int KeyDown(IntPtr dm,int vk);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int KeyUp(IntPtr dm,int vk);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int LeftClick(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int RightClick(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int MiddleClick(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int LeftDoubleClick(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int LeftDown(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int LeftUp(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int RightDown(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int RightUp(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int MoveTo(IntPtr dm,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int MoveR(IntPtr dm,int rx,int ry);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetColor(IntPtr dm,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetColorBGR(IntPtr dm,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string RGB2BGR(IntPtr dm,string rgb_color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string BGR2RGB(IntPtr dm,string bgr_color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int UnBindWindow(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int CmpColor(IntPtr dm,int x,int y,string color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int ClientToScreen(IntPtr dm,int hwnd,ref object x,ref object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int ScreenToClient(IntPtr dm,int hwnd,ref object x,ref object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int ShowScrMsg(IntPtr dm,int x1,int y1,int x2,int y2,string msg,string color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetMinRowGap(IntPtr dm,int row_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetMinColGap(IntPtr dm,int col_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FindColor(IntPtr dm,int x1,int y1,int x2,int y2,string color,double sim,int dir,out object x,out object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string FindColorEx(IntPtr dm,int x1,int y1,int x2,int y2,string color,double sim,int dir);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWordLineHeight(IntPtr dm,int line_height);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWordGap(IntPtr dm,int word_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetRowGapNoDict(IntPtr dm,int row_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetColGapNoDict(IntPtr dm,int col_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWordLineHeightNoDict(IntPtr dm,int line_height);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWordGapNoDict(IntPtr dm,int word_gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetWordResultCount(IntPtr dm,string str);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetWordResultPos(IntPtr dm,string str,int index,out object x,out object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetWordResultStr(IntPtr dm,string str,int index);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetWords(IntPtr dm,int x1,int y1,int x2,int y2,string color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetWordsNoDict(IntPtr dm,int x1,int y1,int x2,int y2,string color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetShowErrorMsg(IntPtr dm,int show);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetClientSize(IntPtr dm,int hwnd,out object width,out object height);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int MoveWindow(IntPtr dm,int hwnd,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetColorHSV(IntPtr dm,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetAveRGB(IntPtr dm,int x1,int y1,int x2,int y2);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetAveHSV(IntPtr dm,int x1,int y1,int x2,int y2);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetForegroundWindow(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetForegroundFocus(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetMousePointWindow(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetPointWindow(IntPtr dm,int x,int y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string EnumWindow(IntPtr dm,int parent,string title,string class_name,int filter);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetWindowState(IntPtr dm,int hwnd,int flag);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetWindow(IntPtr dm,int hwnd,int flag);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetSpecialWindow(IntPtr dm,int flag);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWindowText(IntPtr dm,int hwnd,string text);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWindowSize(IntPtr dm,int hwnd,int width,int height);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetWindowRect(IntPtr dm,int hwnd,out object x1,out object y1,out object x2,out object y2);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetWindowTitle(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string GetWindowClass(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWindowState(IntPtr dm,int hwnd,int flag);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int CreateFoobarRect(IntPtr dm,int hwnd,int x,int y,int w,int h);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int CreateFoobarRoundRect(IntPtr dm,int hwnd,int x,int y,int w,int h,int rw,int rh);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int CreateFoobarEllipse(IntPtr dm,int hwnd,int x,int y,int w,int h);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int CreateFoobarCustom(IntPtr dm,int hwnd,int x,int y,string pic,string trans_color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarFillRect(IntPtr dm,int hwnd,int x1,int y1,int x2,int y2,string color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarDrawText(IntPtr dm,int hwnd,int x,int y,int w,int h,string text,string color,int align);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarDrawPic(IntPtr dm,int hwnd,int x,int y,string pic,string trans_color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarUpdate(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarLock(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarUnlock(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarSetFont(IntPtr dm,int hwnd,string font_name,int size,int flag);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarTextRect(IntPtr dm,int hwnd,int x,int y,int w,int h);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarPrintText(IntPtr dm,int hwnd,string text,string color);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarClearText(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarTextLineGap(IntPtr dm,int hwnd,int gap);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int Play(IntPtr dm,string file_);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FaqCapture(IntPtr dm,int x1,int y1,int x2,int y2,int quality,int delay,int time);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FaqRelease(IntPtr dm,int handle);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string FaqSend(IntPtr dm,string server,int handle,int request_type,int time_out);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int Beep(IntPtr dm,int fre,int delay);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FoobarClose(IntPtr dm,int hwnd);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int MoveDD(In