向某个最小化的外部程序发送按键(或组合键) 我建议你先发送给自已的程序试试,起码自已窗口的句柄是对的你要确保窗口句柄是正确的你可以用findWindow或FindWindwoEx找到窗口的句柄可能你是取到的句柄不对,你可用getwindowText Api 试一下句柄是否正确 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [DllImport("user32")] public static extern unsafe int FindWindow(string sClassName,string WindowName); [DllImport("user32")] public static extern unsafe bool SetForegroundWindow(int hWnd);private bool AppActivate(string sWindowName){int hwind = FindWindow(null,sWindowName);if (hwind == 0) return false;SetForegroundWindow(hwind);return true;}if (AppActivate("notepad")) {System.Windows.Forms.SendKeys.SendWait("%(f)o");....}将notepad最小化,可以发送。 谢谢,你的办法是可以正常运行的。但用这个办法就必须先把记事本放到前台来,这样对正在进行操作的有影响的~,我想用sendmessage就是认为它可以直接向最小化的程序发送消息的~不知道是不是我的理解错误,该函数不能进行这种操作? 如何可能是确保整数可以为3位数 利用VS2008试用版开发软件,是否涉及微软版权问题 播放音乐! 关于Datetime的一个习题。 在编写windows服务的时候,怎样获取服务的Exe文件的当前的物理路径? 怎样禁用Paint与OnPaint事件? 【100高分】怎么更改dataset的列名(更改xml文件节点名称)并保存为本地XML文件 哪里可以下载.net安装盘 刚做了一个组件,在.net实现O/R Mapping思想,组件在测试中。 XML,dataset求教 请问:变量定义问题 SQL7中,表与表互相关联
public static extern unsafe int FindWindow(string sClassName,string WindowName);
[DllImport("user32")]
public static extern unsafe bool SetForegroundWindow(int hWnd);private bool AppActivate(string sWindowName)
{
int hwind = FindWindow(null,sWindowName);
if (hwind == 0)
return false;
SetForegroundWindow(hwind);
return true;
}if (AppActivate("notepad"))
{
System.Windows.Forms.SendKeys.SendWait("%(f)o");
....
}将notepad最小化,可以发送。