得到程序句柄并向他发送ctrl+c,有时能获取,有时得点几次才能获取,前几次都是得到为空,都得到程序的焦点,但为什么得到的为空对象,再点一次也能获取,请高手指教问题在哪? private void button1_Click(object sender, EventArgs e)
{
ParenthWnd =FindWindow(null, name);
if (ParenthWnd != null)
{
if (!ParenthWnd.Equals(IntPtr.Zero))
{
ShowWindow(ParenthWnd, 9);
SetForegroundWindow(ParenthWnd);
ShowWindow(ParenthWnd, 3);
SendKeys.SendWait("^c");
Thread.Sleep(100);
message = Convert.ToString(Clipboard.GetDataObject().GetData(DataFormats.Text));
}
if (!string.IsNullOrEmpty(message))
{
SetForegroundWindow(this.Handle);
Thread th = new Thread(new ThreadStart(getexc));
th.Start();
Thread.Sleep(100); }
{
ParenthWnd =FindWindow(null, name);
if (ParenthWnd != null)
{
if (!ParenthWnd.Equals(IntPtr.Zero))
{
ShowWindow(ParenthWnd, 9);
SetForegroundWindow(ParenthWnd);
ShowWindow(ParenthWnd, 3);
SendKeys.SendWait("^c");
Thread.Sleep(100);
message = Convert.ToString(Clipboard.GetDataObject().GetData(DataFormats.Text));
}
if (!string.IsNullOrEmpty(message))
{
SetForegroundWindow(this.Handle);
Thread th = new Thread(new ThreadStart(getexc));
th.Start();
Thread.Sleep(100); }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货