c#调用winAPI向某一程序发送按键
2013-03-10 19:56
441 查看
1:通过FindWindow找到窗体
2:通过SetForegroundWindow激活找到的窗体
3:发送按键
声明:
调用:
2:通过SetForegroundWindow激活找到的窗体
3:发送按键
声明:
[DllImport("USER32.DLL")] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd);
调用:
IntPtr calculatorHandle = FindWindow(null, "Form1");//窗口名称 if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("not running."); return; } SetForegroundWindow(calculatorHandle); SendKeys.SendWait("111"); SendKeys.SendWait("*"); SendKeys.SendWait("11"); SendKeys.SendWait("=");
相关文章推荐
- C#调用API向外部程序发送数据
- C#中用WinAPI调用外部程序
- C#中用WinAPI调用外部程序
- C#调用WinAPI发送消息SendMessage
- 在C#程序中模拟发送键盘按键消息
- 在C#程序中模拟发送键盘按键消息
- C#中用WinAPI调用外部程序
- c#调用winapi为外部程序控件赋值
- 用C#调用Windows API向指定窗口发送按键消息
- C#中用WinAPI调用外部程序
- 在C#程序中模拟发送键盘按键消息
- C#可调用API接口来获取窗口句柄,发送消息控制其余程序窗体大小
- 用C#调用Windows API向指定窗口发送按键消息 z
- C# 调用Lotus Notes发送邮件
- 在C#中调用控制台程序
- C#程序实现动态调用DLL的研究
- C# winform 通过调用outlook发送邮件
- VS2010下ocx开发:(2)在C#程序中调用ocx控件
- Android不调用第三方程序发送邮件
- C#调用Exe程序示例