日期:2014-05-17 浏览次数:21518 次
/// <summary>
/// 鼠标选取指定区域后copy
/// </summary>
/// <param name="first">起始位置</param>
/// <param name="second">结束位置</param>
/// <returns>copy结果</returns>
static internal string GetClipboardInfo(string first, string second)
{
string result = "";
SetCursorPos(Convert.ToInt32(first.Split('|')[0]), Convert.ToInt32(first.Split('|')[1])); //取需要的区域开始的坐标
mouse_event(0x0002, 0, 0, 0, 0);//按下鼠标左键
SetCursorPos(Convert.ToInt32(second.Split('|')[0]), Convert.ToInt32(second.Split('|')[1]));//取需要的区域结束的坐标
mouse_event(0x0004, 0, 0, 0, 0);//放开鼠标左键
System.Threading.Thread.Sleep(5000); //为了调试方便
//keybd_event(0x1d, 0, 0, 0);
//keybd_event(0x2e, 0, 0, 0);
//keybd_event(0x2e, 0, 2, 0);
//keybd_event(0x1d, 0, 2, 0);
SetCursorPos(172, 128); //把鼠标移到选中文本上
keybd_event(17, 0, 0, 0); //按下ctrl
keybd_event(67, 0, 0, 0); //按下C
keybd_event(67, 0, 2, 0); //放开C
keybd_event(17, 0, 2, 0); //放开ctrl
mouse_event(0x0008, 0, 0, 0, 0);//按下右键
mouse_event(0x0010, 0, 0, 0, 0);//放开右键
System.Threading.Thread.Sleep(5000);
SetCursorPos(225, 259);//鼠标移动到复制选项上
mouse_event(0x0002, 0, 0, 0, 0);//按下左键
mouse_event(0x0004, 0, 0, 0, 0);//放开左键
//SendKeys.SendWait("^c");