/// <summary> /// 设置线程亲和,附到前台窗口所在线程,只有在线程内才可以获取线程内控件的焦点 /// </summary> /// <param name="b">是否亲和</param> private static void AttachThreadInput(bool b) { Win32API.AttachThreadInput( Win32API.GetWindowThreadProcessId( Win32API.GetForegroundWindow(), 0), Win32API.GetCurrentThreadId(), Convert.ToInt32(b)); }