public void CloseThreadInput() { if (targetProcessId != Process.GetCurrentProcess().Id) { WindowsAPI.AttachThreadInput(curThreadId, targetProcessId, 0); targetProcessId = 0; } }
public void OpenThreadInput() { //IntPtr pWin = WindowsAPI.GetForegroundWindow(); int id = 0; targetProcessId = WindowsAPI.GetWindowThreadProcessId(pWin, ref id); if (targetProcessId != Process.GetCurrentProcess().Id) { WindowsAPI.AttachThreadInput(curThreadId, targetProcessId, 1); } }