开发工具:
文件大小: 253kb
下载次数: 0
上传时间: 2014-03-17
详细说明: 模拟键盘鼠标操作飞信界面发送短信 private void SendSMS() { #if DEBUG string[] addr = new string[] { "闻佃来"}; #else string[] addr = new string[] { "张三", "李四"}; #endif string message = " "; if (message == "") return; Rectangle rect = new Rectangle(); Windows wins = new Windows(); IntPtr hwin = IntPtr.Zero; foreach (Window w in wins) { if (w.Title.Ind exOf("发短信") >= 0) { hwin = w.hWnd; break; } } //未找到发送窗口,点击主窗口下的短信发送按钮 if (hwin == IntPtr.Zero) { wins = new Windows(); foreach (Window w in wins) { if (w.Title.IndexOf("飞信2013") >= 0) { //唤醒屏保 Win32.SetCursorPos(10,10); Win32.mouse_event(Win32.MOUSEEVENTF_MOVE, 50, 50, 0, 0); Thread.Sleep(1500); Win32.ShowWindow(w.hWnd, Win32.SW_SHOWNORMAL); Win32.SetForegroundWindow(hwin); Win32.GetWindowRect(w.hWnd, ref rect); IntPtr hDesk = Win32.GetDesktopWindow(); Rectangle rdesk = new Rectangle(); Win32.GetWindowRect(hDesk,ref rdesk); if (rect.Y < 0) { //上 Win32.SetCursorPos(rect.X +(rect.Width-rect.X)/2,0); Win32.mouse_event(Win32.MOUSEEVENTF_MOVE, 0, 1, 0, 0); Thread.Sleep(1500); Win32.GetWindowRect(w.hWnd, ref rect); } else if (rect.Y >= rdesk.Height - 3) { //下 Win32.SetCursorPos(rect.X + (rect.Width - rect.X) / 2,rdesk.Height); Win32.mouse_event(Win32.MOUSEEVENTF_MOVE, 0, -1, 0, 0); Thread.Sleep(1500); Win32.GetWindowRect(w.hWnd, ref rect); } else if (rect.X <= 0) { //左边 Win32.SetCursorPos(0, rect.Y + (rect.Height - rect.Y) / 2); Thread.Sleep(2000); Win32.mouse_event(Win32.MOUSEEVENTF_MOVE, 1, 0, 0, 0); Thread.Sleep(1500); Win32.GetWindowRect(w.hWnd, ref rect); } else if (rect.X >= rdesk.Width - 3) { //右边 Win32.SetCursorPos(rdesk.Width, rect.Y + (rect.Height - rect.Y) / 2); Thread.Sleep(2000); Win32.mouse_event(Win32.MOUSEEVENTF_MOVE, -1, 0, 0, 0); Thread.Sleep(1500); Win32.GetWindowRect(w.hWnd, ref rect); }else { Win32.MoveWindow(w.hWnd, rect.Left, 0, rect.Width - rect.Left, rect.Height - rect.Top, true); Win32.GetWindowRect(w.hWnd, ref rect); Thread.Sleep(300); } Win32.SetCursorPos(rect.X+70,rect.Height-50); Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN | Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Thread.Sleep(2000); break; } } //再次查找发送窗口 wins = new Windows(); foreach (Window w in wins) { if (w.Title.IndexOf("发短信") >= 0) { hwin = w.hWnd; break; } } } //查询发送窗口成功 if (hwin != IntPtr.Zero) { Win32.ShowWindow(hwin, Win32.SW_SHOWNORMAL); Win32.SetForegroundWindow(hwin); Win32.GetWindowRect(hwin, ref rect); IntPtr hwndtel = Win32.WindowFromPoint(rect.Left + 120, rect.Top + 45); IntPtr hwndsend = Win32.WindowFromPoint(rect.Left + 50, rect.Height - 60); //单击地址栏 Win32.SetCursorPos(rect.Left + 120, rect.Top + 45); Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN | Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Thread.Sleep(1000); //加入地址 for (int i = 0; i < addr.Length; i++) { Clipboard.SetText(addr[i]); Thread.Sleep(200); Win32.SendMessage(hwndtel, Win32.WM_PASTE, 0, 0); Thread.Sleep(300); Win32.SendMessage(hwndtel, Win32.WM_KEYDOWN, 0X0D, 0);//发 Win32.SendMessage(hwndtel, Win32.WM_KEYUP, 0X0D, 0); //送 Win32.SendMessage(hwndtel, Win32.WM_CHAR, 0X0D, 0); //回车 Thread.Sleep(300); } //加入消息文本 Clipboard.SetText(message); Thread.Sleep(200); Win32.SendMessage(hwndsend, Win32.WM_PASTE, 0, 0); Thread.Sleep(200); #if DEBUG #else if (!_TestMode) { Win32.SendMessage(hwndsend, Win32.WM_KEYDOWN, 0X0D, 0); Win32.SendMessage(hwndsend, Win32.WM_KEYUP, 0X0D, 0); Win32.SendMessage(hwndsend, Win32.WM_CHAR, 0X0D, 0); } #endif textBox1.AppendText("---------------------------------------- \n"); textBox1.AppendText(DateTime.Now + ":"+ message + "\n"); } else { textBox1.AppendText("无法打开飞信短信发送窗口\n"); } _LastSend = DateTime.Now; LastSendTime = _LastSend; } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.