我在按钮用SENDKEYS.SEND()发送其它窗口时能发出键值,在自己程序里发现窗口为什么发不出键值?
代码:
IntPtr hd = FindWindow("Internet Explorer_TridentDlgFrame", "修改密码 -- 网页对话框");
if (hd != IntPtr.Zero) //修改密码失败
{
Rectangle rc = new Rectangle();
GetWindowRect(hd, ref rc);
SetWindowPos(hd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Cursor.Position = new Point(rc.Left + 180, rc.Top + 50); //新密码
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0);
System.Windows.Forms.SendKeys.Send(passw); System.Windows.Forms.SendKeys.Send("{TAB}"); System.Windows.Forms.SendKeys.Send(passw);
Cursor.Position = new Point(rc.Left + 140, rc.Top + 105);
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0); }
麻烦高手帮忙查看下原码 其中passw是全程变量,有值。
代码:
IntPtr hd = FindWindow("Internet Explorer_TridentDlgFrame", "修改密码 -- 网页对话框");
if (hd != IntPtr.Zero) //修改密码失败
{
Rectangle rc = new Rectangle();
GetWindowRect(hd, ref rc);
SetWindowPos(hd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Cursor.Position = new Point(rc.Left + 180, rc.Top + 50); //新密码
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0);
System.Windows.Forms.SendKeys.Send(passw); System.Windows.Forms.SendKeys.Send("{TAB}"); System.Windows.Forms.SendKeys.Send(passw);
Cursor.Position = new Point(rc.Left + 140, rc.Top + 105);
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0); }
麻烦高手帮忙查看下原码 其中passw是全程变量,有值。
解决方案 »
- tableLayoutPanel控件对齐
- 求改错,几行的socket代码,摆脱各位
- 如何实现当客户端一收到信息,服务器端就马上提示发送成功(象QQ的小喇叭消息提示那样)
- 从不是创建控件 lbClient 的线程访问它,这是什么原因,怎么解决?
- System.Threading.Thread.Sleep(i);这句话是什么意思 ?
- 看一段C#程序:关于浮点余数的计算规则
- datagrid问题?把数据库显示出来的某行通过textbox等控件列出来
- 应该是.net代码编辑器的问题!具体请进来看!不知你们有没有碰到过?有没有办法解决?
- 跪求啊
- 请教个初学者问题:如何自定义一个sqlconnection类?
- net 如何调用java的一个类呢
- 报表
api : SendInput
hd = FindWindow("Internet Explorer_TridentDlgFrame", "修改密码 -- 网页对话框");
if (hd != IntPtr.Zero) //修改密码失败
{
Rectangle rc = new Rectangle();
GetWindowRect(hd, ref rc);
SetWindowPos(hd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Cursor.Position = new Point(rc.Left + 180, rc.Top + 50); //新密码 mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0); SendKeys.Send(passw); SendKeys.Send("{TAB}"); SendKeys.Send(passw);
k++;
if (k == 3)
{
Cursor.Position = new Point(rc.Left + 140, rc.Top + 105);
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, 0);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, 0);
k = 0;
w_state++;
}
}