void ActiveWin(IntPtr h) { IntPtr hForeWnd = GetForegroundWindow();//获取当前窗口句柄 int tIdCur = GetWindowThreadProcessId(hForeWnd, IntPtr.Zero);//获取当前窗口句柄的线程ID int tIdCurProgram = GetCurrentThreadId();//获取当前运行程序线程ID var r = AttachThreadInput(tIdCur, tIdCurProgram, 1);//是否能成功和当前自身进程所附加的输入上下文有关 //SwitchToThisWindow(h, true); //ShowWindow(hJD, 9); BringWindowToTop(h); //SetForegroundWindow(h); //SetActiveWindow(hJD); //SetFocus(hJD); AttachThreadInput(tIdCur, tIdCurProgram, 0); }
void TopWin(IntPtr h) { SetWindowPos(h, -1, 0, 0, 0, 0, 1 | 2 | 10 | 40); }