资源简介
用C#实现类似Microsoft Spy 的小程序
代码片段和文件信息
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
public class GrabScreen_XDICT : XDICTGRB.IXDictGrabSink
{
int tick;
public GrabScreen_XDICT(int tick = 200) { this.tick = tick; }
string tmpStr;
int XDICTGRB.IXDictGrabSink.QueryWord(string WordString int lCursorX int lCursorY string SentenceString ref int lLoc ref int lStart)
{
if (GrabNewString != null && tmpStr != SentenceString)
{
tmpStr = SentenceString;
GrabNewString(tmpStr);
}
return 1;
}
public delegate void GrabNewStringDelegate(string str);
public event GrabNewStringDelegate GrabNewString;
XDICTGRB.GrabProxy gp;
volatile bool grabing;
public void StartGrabWord(Point point)
{
if (gp == null)
{
gp = new XDICTGRB.GrabProxy();
gp.GrabEnabled = false;
gp.AdviseGrab(this);
}
else if (grabing)
{
StopGrabWord();
Thread.Sleep(tick + 100);
Application.DoEvents();
}
Thread thread = new Thread(new ParameterizedThreadStart(GrabThread));
thread.IsBackground = true;
grabing = true;
thread.Start(point);
}
public void StopGrabWord() { grabing = false; }
private void GrabThread(object point)
{
var p = (Point)point;
while (grabing && !Application.OpenForms[0].Disposing)
{
try { gp.GrabWord(p.X p.Y); }
catch { }
Thread.Sleep(tick);
}
}
}
/*
//if (grab == null)
//{
// grab = new GrabScreen_NHW();
// grab.GrabNewString += new GrabScreen_NHW.GrabNewStringDelegate(grab_GrabNewString);
// btnGrab.Text = “Stop&Grab“;
// grab.StartGrabWord(handle (Point)btnGetHdl.Tag);
//}
//else
//{
// grab.StopGrabWord();
// grab.GrabNewString -= new GrabScreen_NHW.GrabNewStringDelegate(grab_GrabNewString);
// grab = null;
// btnGrab.Text = “&GrabWord“;
//}
*/
/*
public class GrabScreen_NHW
{
private enum SetFlag : uint
{
GETWORD_ENABLE = 1000
GETWORD_DISABLE = 1002
}
[DllImport(“Nhw32.dll“)]
private static extern uint BL_SetFlag32(SetFlag nFlag IntPtr hWnd int pX int pY);
[DllImport(“Nhw32.dll“)]
private static extern uint BL_GetText32(StringBuilder strBuf int bufSize ref Rectangle rect);
[DllImport(“Nhw32.dll“)]
private static extern bool SetNHW32();
[DllImport(“Nhw32.dll“)]
private static extern bool ResetNHW32();
int tick;
volatile bool grabing;
public GrabScreen_NHW(int tick = 100) { this.tick = tick; }
public delegate void GrabNewStringDelegate(string str);
public event GrabNewStringDelegate GrabNewString;
IntPtr handle;
Point point;
public bool StartGrabWord(IntPtr hWnd Point point)
{
if (grabing) StopGrabWord()
- 上一篇:HEXtoASCII码之间的相互转换
- 下一篇:C# usb hid 设备控制
相关资源
- C# usb hid 设备控制
- Unity 房间游览
- 寿星万年历的c#实现版本sxtwl_csharp_t
- TcpClient C#2010读取PLC
- C# 远程开机和关机
- C#实现特殊主框架界面效果
- C#会员管理条码版(附数据库)
- C#获取U盘信息
- C#教程(非常基础)
- C#打开与获取网页源码
- C# Cad2006二次开发之图形扩展属性读写
- C# 棋牌室小软件(附数据库以及源码
- c# 串口通讯的(收发数据)
- C#-与西门子1200-1500-S7通讯(源码+文档
- C# 朗读文本文字(SpeechSynthesizer)
- C#_基础教程笔记(传智播客)-苏坤
- C#联合halcon实现鼠标滚轮事件
- C# 异型窗口,圆形窗口
- CSharp language specification 5.0中文(C# 语
- asp.netc#开发规范
- C# 固高运动卡(gts.dll)
- C#写的文件读写
- C#网站项目使用SignalR技术实现实时聊
- C#控制雷赛驱动器定长运动
- C#简单连接查询sqlite数据库
- C#控制雷赛驱动器单轴点位运动
- C#控制雷赛板卡回原点
- C#控制雷赛板卡连续运动
- C#控制雷赛板卡两轴圆弧插补
- C#控制雷赛板卡两轴直线插补
评论
共有 条评论